Copy link to clipboard
Copied
var top:MovieClip = MovieClip(root);
top.menu3.addChild(member[i-1].scenarioplayed); |
I want to add components to a movieclip depending on value of i.
The movieclips are named menu3, menu4, etc.
Is there a way to make all are part of "top.menu3" a variable?
I tried this but got a compile error:
Symbol 'scene3', Layer 'Actions', Frame 1, Line 161 | 1061: Call to a possibly undefined method addChild through a reference with static type String. |
var menuName:String;
menuName = "top.menu5";
menuName.addChild(member[i-1].scenarioplayed);
For the code you just showed, menuName is a String. String do not have an addChild method.
It is not clear what you are working with to get what you want, but if you want to use String values to target objects you can use the bracket notation...
var menuObject:MovieClip = top["menu5"];
menuObject.addChild(member[i-1].scenarioplayed);
Copy link to clipboard
Copied
For the code you just showed, menuName is a String. String do not have an addChild method.
It is not clear what you are working with to get what you want, but if you want to use String values to target objects you can use the bracket notation...
var menuObject:MovieClip = top["menu5"];
menuObject.addChild(member[i-1].scenarioplayed);
Copy link to clipboard
Copied
Can menu5 then be a variable?
var menu:string = "menu5";
var menuObject:MovieClip = top[menu]; // Can variable be placed here
menuObject.addChild(member[i-1].scenarioplayed);
I went to use a switch statement to send component to right movieclip.
switch (true)
{
case i > 34:
{
q = 34;
menu = "menu5";
break;
}
case i > 17:
{
q = 17;
menu = "menu4";
break;
}
case i < 18:
{
q = 0;
menu = "menu3";
break;
}
then add following for placement
var menuObject:MovieClip = top[menu]; // Can variable be placed here
menuObject.addChild(member[i-1].scenarioplayed);
Copy link to clipboard
Copied
BTW, I have the project I am working on up at http://www.ragtopvideo.com/testpage.html
The team link is the only one working now. It can do up to 17 team members, this part
is meant to spill over larger numbers onto other pages/movieclips.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now