Skip to main content
Known Participant
November 8, 2016
Question

gotoAndPlay not working adding library item using new lib.xxxx

  • November 8, 2016
  • 0 replies
  • 189 views

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.

This topic has been closed for replies.