Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

AS3 Targetting

Explorer ,
Feb 17, 2017 Feb 17, 2017

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?

TOPICS
ActionScript
313
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 17, 2017 Feb 17, 2017

How are the movieclips created?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 17, 2017 Feb 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 17, 2017 Feb 17, 2017
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 17, 2017 Feb 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 .

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines