When slow-down IS caused by code, it's usually because of loops. Such as when checking for collisions or searching for something.
The key is to figure out ways to reduce the size of "for" loops, or even look for some alternative ways that don't use looping at all. For instance, the collision-checking example below doesn't require any searching or hitTest() functions to find the walls. Instead it uses a 2-dimensional array and simply checks a location within it. This is useful for colliding with stationary blocks in a level.
If you're checking for collision with every character, figure out ways to exclude movieClips you're not looking for. Check only the things you need to check.
One way to do this is to make an array of references to each movieClip you wish to check, and simply loop through that array. The first step in collision checking is usually figuring out what to ignore.Download Source
Or find ways to reduce the number of collision checks. For example, have characters check for blocks, instead of having blocks check for characters. Since there are fewer characters than blocks, it'll use fewer collision checks.