PDA

View Full Version : class with movie clip actions



GrndMasterFlash
August 9th, 2007, 11:29 AM
ok, i use addChild to load a character (MC) from the library and take actions, if i reffer to the MC the new caracter loads into i can get simple direction control, only because the child is attached to the parent, but when i try to do somthing like a goto command it will not work,

the simple script


player.addChild(new emilia);
trace(emilia); // output = [class emilia]
trace(player); // output = [object MovieClip]
player.x = 200;
player.y = 490;
emilia.gotoAndStop("duck");

is there a way for me to be able to load in "emilia" as its own MC to be able to receive time line controls?

senocular
August 9th, 2007, 11:31 AM
emilia is your class, not your instance. You want player.getChildAt(0) (or whatever depth the new emilia was placed)

sangackt
August 9th, 2007, 12:11 PM
The code you wrote:

emilia.gotoAndStop("duck");

that doesn't reference the new movieclip object you created ealier. You can do it two ways, like Senocular said:
player.getChildAt(n) (Where n is wherever the object is in the heirarchy)
or
var mycharacter:emilia = new emilia();
mycharacter.gotoAndPlay( "duck" );

GrndMasterFlash
August 9th, 2007, 12:18 PM
sweet, im back on track thanx m8
:bounce: