Skip to main content
Participant
December 3, 2008
Question

randomly jump to a frame

  • December 3, 2008
  • 2 replies
  • 464 views
I have an animation where I want to play a movie clip and then play another movie clip from the library (selecting randomly from a group of movie clips). I couldn't figure out how to get this to work, so I tried to play the first clip, and when it gets to its last frame jump to a random clip which is already on the time line. The AS is attached.

Clearly I'm missing something critical here. Any help is appreciated.

Thanks.
This topic has been closed for replies.

2 replies

Participant
December 4, 2008
Thanks for the help.

Do I need to tell the mc to play once it has been added to the timeline? I added a trace to the movie clips and it isn't showing up in the output window.

Also, I'm getting a compile error in the movie clip:
1061: Call to a possibly undefined method gotoAndPlay through a reference with static type flash.display:DisplayObjectContainer.

Any idea why?

Thanks.
Ned Murphy
Legend
December 3, 2008
It's not really clear what you are trying to accomplish with what you are showing. Based on what you described, where the mc's are in the timeline, you don't need any conditionals, and you probably don't need any commands to jump to a new frame, except for one that goes back to frame 1.

It almost seems as though you started describing one thing you wanted to do, and then another different approach, so it's hard to really tell what you have and what you want.
Participant
December 4, 2008
Sorry, ignore the previous question --

At a particular frame -- say frame 200, I want to play a randomly selected movie clip from the library, and then go back to frame one after it finishes playing. How would this be accomplished?
clbeech
Inspiring
December 4, 2008
in order to attach a Lib MC under AS3 you need to invoke a constructor, so you have two choices, you can either instantiate all of your clips 'up front' and the use addChild as needed, or specify the 'name' of the clip and create a dynamic constructor. in both cases, an array would be used to store the data and then a use a random index for the selection. so you're kind of on the right track. you are correct that you will need a call back to the main timeline to return to frame one, however you won't need the conditional statement if you place the code on a keyframe on the final frame - you should also 'remove' the clip from the stage once it is complete. something like this: