Copy link to clipboard
Copied
Having some real issues with some simple AS3 targetting.
I have three movie clips "mc1" mc2" and "mc3" inside a Movieclip called selector. This script appears in a Selector.as file attached to the outer movie.
var mcArray:Array=[mc1,mc2,23];
public function resetBtn(){
for(var i:Number=0;i<=2;i++){
//mcArray.gotoAndStop(bgNo);
trace("i = "+mcArray[0]+" ");
}
}
When I call the function resetBtn the mcArray trace comes back with i = NULL. If I change the mcArray values to numbers or strings this appears to work. Do I somehow need to tell the for loop that I am targetting a movieClip or change the array to specify that the mc names are movieClips?
Copy link to clipboard
Copied
How are the movieclips created?
Copy link to clipboard
Copied
they are in the scene at root.level of the selectorMc. So path from root would read :
_root.selectorMc.mc1
_root.selectorMc.mc2
_root.selectorMc.mc3
and the actions are applied from using a document class attached to selectorMc, called selector.as
Copy link to clipboard
Copied
Can you show more of the code in the class file?
Copy link to clipboard
Copied
There are some mistakes in your script, try fixing those and see if that helps.
In the array you have '23' instead of 'mc3'.
In the repeat loop you're using a Number instead of int. That may work but you shouldn't do it.
You are always tracing array[0] and not array .