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

gotoAndPlay not working adding library item using new lib.xxxx

Community Beginner ,
Nov 08, 2016 Nov 08, 2016

I am dynamically creating my content by adding content from the library as follows:

var newBall = new lib.ball();

this.addChild(newBall);

The ball movie clip is added to the stage with the above code.

My ball movie clip has 4 keyframes, each of which is a different ball graphic.

I would like to set the keyframe after adding the ball to the "stage" and have tried the following:

newBall.gotoAndStop(2);

This has no effect.

I am assuming the issue is that the ball has not been instantiated yet so I would like to know how to check the ball has been instantiated before calling the  gotoAndPlay code? I was thinking I could call it after a small delay but I would prefer a more robust solution.

162
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
no replies

Have something to add?

Join the conversation