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

tell a child gotoAndPlay(X) from a code in timeline of another child.

Contributor ,
Jun 18, 2013 Jun 18, 2013

Hi there!

I have tried to simplify my bigger question in the following example.

(Also you may download this FLA if needed)

what do I have:
- an EMPTY scene.
- 2 movieclips in library (m1mc , m2mc)

I use addChild method to add them to stage (m1=m1mc , m2=m2mc). this is the code in Frame 1 of empty scene:

var m1:m1mc = new m1mc();
var m2:m2mc = new m2mc();

addChild(m1);
addChild(m2);

m1.x = 100;
m2.x = 300;

"m1mc" contains some frames that in frame 1 I have asked it to stop:


stop();

And finally my questions is:

HOW to write a code in frame 1 of "m2mc" (that is in library) to tell "m1mc" gotoAndStop frame 2 (in this example)??

I CAN access and change the alpha of "m1mc" from the timeline of "m2mc" with this code:

parent.getChildAt(0).alpha = 0.5; //works fine

but I CAN'T use the same method to tell "m1mc" gotoAndStop(someFrame)

parent.getChildAt(0).gotoAndStop(2);

//Error Symbol 'm2mc', Layer 'Layer 2', Frame 1, Line 2 1119: Access of possibly undefined property gotoAndStop through a reference with static type flash.display:DisplayObject.

Any help would be highly appreciated 

TOPICS
ActionScript
1.1K
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

correct answers 1 Correct answer

Community Expert , Jun 18, 2013 Jun 18, 2013

that code is poor but you could use:

MovieClip(parent.getChildAt(0)).gotoAndStop(2);

Translate
Community Expert ,
Jun 18, 2013 Jun 18, 2013

that code is poor but you could use:

MovieClip(parent.getChildAt(0)).gotoAndStop(2);

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
Contributor ,
Jun 18, 2013 Jun 18, 2013

WOW kglad, the whole night I was searching for this formula you just offered!! WELLDONE man!!

Wish you all the best and take care

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
Community Expert ,
Jun 19, 2013 Jun 19, 2013
LATEST

you're welcome.

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