-
Accessing a MC via a variable string reference
Code:
var possibleName:String = "mcIReallyWantThisClip";
possibleName.addChild(mcChildClip);
Just wondering if there's an easy way to add the child to the "mcIReallyWantThisClip" rather than a clip called "possibleName"...
(I've used getDefinitionByName, but that seems to wants me to create a new instance of mcIReallyWantThisClip.)
-
Right now what you are doing is trying to call the addChild Method of a string... That obviously doesn't work. From your code I am assuming you already have a MovieClip called mcIReallyWantThisClip created and on the stage somewhere. In that case you need to do the following:
Code:
var possibleName:MovieClip = getChildByName("mcIReallyWantThisClip");
possibleName.addChild(mcChildClip);
-
hippie hater
No,what he was trying to do is create a clip and use the string possibleName to reference it
PHP Code:
var possibleName:String = "mcIReallyWantThisClip";
this[possibleName] = new MovieClip();
addChild(this[possibleName]);
this[possibleName].x = 10;
trace(this.mcIReallyWantThisClip.x);//10
-
Cimmerian, that's exactly what I wanted, thank you! Sorry I wasn't more clear, JHarlequin.
Thanks again.
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
|