walker6o9
asked on
Add MovieClips to stage
I'm trying to display a bunch of movie clips on the screen. I know I could just place them there, define their property name, and work with them in the code, but I have to place 100 of them, so it would be much easier to do it in the code. I'm working in AS3 with the Flash IDE.
ASKER
I have a movie clip called balloon. To place them on the stage, I just dragged them onto the stage from the library, then called then balloon1_mc, balloon2_mc, etc. I'd like to place them all on the stage without doing that so that I can reference them in my code later on, and move them around, etc.
ASKER
So basically, this is how I'm adding one movie clip to the stage.
var balloon_mc1 = new balloon();
this.addChild(balloon_mc1) ;
How do I do this for 100 of these movie clips, without typing
var balloon_mc1 = new balloon();
this.addChild(balloon_mc1) ;
var balloon_mc2 = new balloon();
this.addChild(balloon_mc2) ;
var balloon_mc3 = new balloon();
this.addChild(balloon_mc3) ;
etc, etc
var balloon_mc1 = new balloon();
this.addChild(balloon_mc1)
How do I do this for 100 of these movie clips, without typing
var balloon_mc1 = new balloon();
this.addChild(balloon_mc1)
var balloon_mc2 = new balloon();
this.addChild(balloon_mc2)
var balloon_mc3 = new balloon();
this.addChild(balloon_mc3)
etc, etc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It looks like you need a loop - like:
// Array referencing your movie clips
var clips:Array=[mc001, mc002, mc003, ...., mc100]
// Loop adding the clips
for(var i:int=0; i<clips.length; ++i){
addChild(clip[i])
}
To give you a better answer pleaser try to elaborate on what you want done,
how you create your movie clips (script/stage/library or loaded) etc.
Best,
Jakob E