PDA

View Full Version : Movie Clip Holder in ActionScript 3.0


ramuk_looc
06-13-2011, 01:28 AM
Hi I am a newbie to AS3.0. While trying to convert a as2.0 script to 3.0.. i encountered some problems.. Home someone here sorts it out for me..


I have an object obj0. I'm trying to make it a holders for a movie clips "mov".
What is the as 3.0 equivalent for the 2nd line in the code. And is it possible to access root as in the 1st line?

var clip = _root["obj"+k];
clip.mc.holder.attachMovie("mv"+k, "mov", 1);
clipArray[k] = clip;

I am a newbie.. So please bear with me if the question sounds noobish...

Ravi Bhadauria
06-13-2011, 03:22 AM
Hi,

In ActionScript 2.0 you can not attach movieClips from library like that.

attachMovie method has been replaced in ActionScript 3.0 completely. Even you can't specify identifier in AS 3.

I m giving you a brief idea on calling movieClips from the library in AS3:

You have to specify a class name for the movieClip in linkage panel from library. Then write code on the first frame of the timeline.

Suppose class name for the movieclip you specified was "Box".

Then put this code on the first frame of the timeline:

var myBox:MovieClip = new Box();
addChild(myBox);
myBox.x = 200;
myBox.y = 150;

and for the holder movieClip, I would repeat same process from the Ball movieClip here:

var myBall:MovieClip = new Ball();
myBox.addChild(myBall);
myBall.x = 200;
myBall.y = 150;

Here Ball is the class name for another movieClip.
and then i attached Ball class to myBox. so myBox is a holder for the Ball class.

thanks
I hope it will help u out.