Copy link to clipboard
Copied
I have several moviclips on stage named. "moviClip1" "moviClip2" "moviClip3"
I'm generating a random number to choose a specific moviclip and change their x,y
how do I call them ?
moviClip+[randomNumber].x = ...
sure but you don't need to call the movieclip inside the row.
var arr:Array = [mc1,mc2,mc3,mc4]; // => this are real movieClips ,not strings (however you can also use strings and call them with this["mcxx"].
so to call the mc just do
arr[0].x = xx;
arr[1].y = xx;
now if you use strings in your array:
this[arr[0]].x = xx;
etc...
Copy link to clipboard
Copied
you shoud not use only numbers to name a mc.
so let's say:
var name1:String = "mc1";
to call it (if you are on the timeline)
this[name1].x = 120;
Copy link to clipboard
Copied
can I use an array ?
function setPage1(): void {
var pageArray: Array = new Array();
pageArray[1] = _myContent.page1;
pageArray[2] = _myContent.page2;
pageArray[3] = _myContent.page3;
pageArray[randPage1].x = _myContent.place1.x;
pageArray[randPage1].y = _myContent.place1.y;
}
Copy link to clipboard
Copied
sure but you don't need to call the movieclip inside the row.
var arr:Array = [mc1,mc2,mc3,mc4]; // => this are real movieClips ,not strings (however you can also use strings and call them with this["mcxx"].
so to call the mc just do
arr[0].x = xx;
arr[1].y = xx;
now if you use strings in your array:
this[arr[0]].x = xx;
etc...
Find more inspiration, events, and resources on the new Adobe Community
Explore Now