Skip to main content
stuartf76130223
Inspiring
February 17, 2017
Question

AS3 Targetting

  • February 17, 2017
  • 2 replies
  • 348 views

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?

This topic has been closed for replies.

2 replies

Colin Holgate
Inspiring
February 17, 2017

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 .

Ned Murphy
Legend
February 17, 2017

How are the movieclips created?

stuartf76130223
Inspiring
February 17, 2017

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

Ned Murphy
Legend
February 17, 2017

Can you show more of the code in the class file?