Code to make flash animations start at a random key frame?

  • PearlWhiteMedia
  • Born
  • Born
  • PearlWhiteMedia
  • Posts: 4

Post 3+ Months Ago

I have a image slideshow set up on a time line. Each image is on a different layer and I am looking for a code to make the flash animation start at a random key frame every time the page is loaded. Here is a link to the site I am working on:

https://jag-designs.sslpowered.com/uniq ... index.html


Thanks for your help!

Josh
Pearlwhitemedia.com
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • PearlWhiteMedia
  • Born
  • Born
  • PearlWhiteMedia
  • Posts: 4

Post 3+ Months Ago

Could anyone help me out with this? Thanks
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

On your action script on your first frame try

Code: [ Select ]
myMovieClip.onEnterFrame = function () {
    trace ("onEnterFrame called");
        gotoAndStop(random(5)); //where 5 is the total number of keyframes
};
  1. myMovieClip.onEnterFrame = function () {
  2.     trace ("onEnterFrame called");
  3.         gotoAndStop(random(5)); //where 5 is the total number of keyframes
  4. };


This example is where I got the idea except it does it with a button onRelease.
http://www.flash.0tutor.com/archive/131 ... rame.shtml

I think that for it to work all your frames in your movieclip are probably going to need to be keyframes. I don't think (random()) differentiates between regular frames and keyframes.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 9 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.