PDA

View Full Version : Dinamic loading MovieClips from library


Qky
05-16-2008, 09:36 PM
Hey all!

Please help! :)

Well, I have a few clips in library and few bottons on the stage.
Botton instance names: btn1, btn2...
Clip instance names: btn1Anim, btn2Anim...

And folowing code:



btn1.addEventListener(MouseEvent.CLICK, MovieClipIn)
btn2.addEventListener(MouseEvent.CLICK, MovieClipIn)

...


function MovieClipIn(e:Event):void{
var AnimName:String = e.target.event + "Anim";
var movie:AnimName = new AnimName();
movie.x = 0;
movie.y = 150;
addChild(movie);
}


It does't work!
....

Thank you...

TomMalufe
05-16-2008, 09:46 PM
Well yeah! That's not going to work at all!

I can hardly tell what you want this to do...

Try this:
btn1.addEventListener(MouseEvent.CLICK, MovieClipIn)
btn2.addEventListener(MouseEvent.CLICK, MovieClipIn)

...


function MovieClipIn(e:Event):void{
var movie:DisplayObject = new this[e.currentTarget.name + "Anim"]();
movie.x = 0;
movie.y = 150;
addChild(movie);
}

although it's going to just place multiple movies over top of each other at (0,150) when you click on more then one button...

If that doesn't work then... try and think of a better way to approach the problem I guess.