6 Replies Latest reply on May 2, 2007 6:24 AM by nITiNkIlLeRmEeRuT

    Random start on timeline

    kjulp
      HI!

      I have made a 10 picture slideshow witch loads on the main site. My question is how I make the slideshow begin with a different picture each time you open the site. The slideshow is a really simple timeline with motiontweens. So im looking for a script in the first frame of the timeline that jumps to a random picture in the slide show.

      Thanx

      K
        • 1. Re: Random start on timeline
          michaeltowse Level 1
          If you number the images which you are loading numerically then you could just pull in a random numeric using flash's maths functions. Don't have a script handy but sure there would be something in the online help to show the direction.
          • 2. Random start on timeline
            nITiNkIlLeRmEeRuT Level 1
            if you use array to store the image names then it should work...
            • 3. Re: Random start on timeline
              kjulp Level 1
              ok thanks but I have converted the images to graphics so that I can make alpha 0-100% tweening - Can't I just jump to random frames, or label each frame where a new picture(graphic) tween starts and then jump to a random label name from the first frame?
              • 4. Random start on timeline
                nITiNkIlLeRmEeRuT Level 1
                then push the frame numbers in an array and use the above approach

                suppose for 1st slideshow > frame 1 -10
                for 2nd slideshow > frame 11 -30
                for 3rd slideshow > frame 31 -50 and so on
                push

                imageArray = new Array(1,11,31);


                rather then using the frame numbers use frame labels instead so in case u increase or decrease the animation it will not effect the code..
                put frame labels in the array instead of frame numbers
                • 5. Re: Random start on timeline
                  kjulp Level 1
                  Ok.. I just get the output screen with this: 4,5,8,6,7,2,9,10,3,1 but the timeline starts at the first frame everytime....
                  I have labeled each frame, with a new pic, from 1-10.... and added this in the first frame of the timeline:

                  Array.prototype.shuffle = function( b ) {
                  var i = this.length, j, t;
                  while( i ) {
                  j = Math.floor( ( i-- ) * Math.random() );
                  t = b && typeof this .shuffle!=='undefined' ? this.shuffle() : this ;
                  this
                  = this[j];
                  this[j] = t;
                  }
                  return this;
                  };

                  imageArray = new Array("1", "2", "3","4","5","6","7","8","9","10");
                  imageArray.shuffle();

                  trace(imageArray);
                  • 6. Random start on timeline
                    nITiNkIlLeRmEeRuT Level 1
                    remove animation from first frame and shift it to 11th frame

                    call the below function everytime animation finishes or use setinterval to call this function if all animations are of same duration

                    quote:

                    _root.callFrameLabel();


                    If you are still unable tyo make it zip and upload the fla somewhere