|
-
No, you don't need to give them instance names - just converting them to symbols will automatically make them children of the wallsMC movieclip, and wallsMC.numchildren and wallsMC.getChildAt() will work automatically.
If you want to know which child (ie which wall in your case) gets assigned which index (eg getChildAt(0), or getChildAt(1), etc.), flash will assign them automatically depending on the layer they are on in your container movieclip. (At the left of the movieclip's timeline where you can add layers). The layer closest to the bottom will get index 0. This can be useful - I sometimes set up the levels of a game in this way, with each level on a separate layer of a container MC, and then call levelContainerMC.getChildAt(level-1) to get that level up and running. (The -1 because child indexes start at 0). The advantage of this is that if you have lots of levels and want to fiddle with the order, you can just drag the layers up and down in the container MC - which is much quicker than if you gave each level an instance name like level1, level2 - as you'd have to keep changing their names when you fiddled with the level order.
If you happen to put all the walls on one single layer, then the order they were created will be the effective layer and hence the child index.
Of course, you can still give instance names to your walls if you want - which would allow you to reference them by name in your code. Say if you wanted a wall which moves up or down - give that particular wall an instance name of 'movingWall', so that in your code you could say wallsMC.movingWall.y += 1. Again - only possible if the wall is a symbol.
Hope that helps.
Last edited by _Ric_; 04-16-2009 at 06:27 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|