Skip to main content
Participating Frequently
April 2, 2007
Question

SOS SWF in a web page

  • April 2, 2007
  • 12 replies
  • 798 views
Am new in the Flash word.
I do have an SWf movie file embedded in a web page. This flash movie is a sequence images. The problem is that I want the movie to randomly start with a different image each time the web page is loaded.

Any help!!!!
This topic has been closed for replies.

12 replies

kglad
Community Expert
Community Expert
April 4, 2007
you're welcome.
Participating Frequently
April 4, 2007
thanks a lot, I think now I know where to start
kglad
Community Expert
Community Expert
April 4, 2007
use the sharedobject to store the inital frame. if none is stored (ie, first view) start with 1, advance frames in order and store 1 in the sharedobject

if an initial frame is stored generate a random number in the correct range until a number different from the stored one is generated. start with that frame, advance in order and store that number in the sharedobject.
Participating Frequently
April 4, 2007
When I reload the HTML form, the SWF Starts at a radom frame. After starting at the random frame the SWF should finish the sequence, meaning lets say randomly the swf starts at frame 4 then the next frame should be 5, then,1,2,3,...and so on but only when I reload the page

Thanks a lot for the help
kglad
Community Expert
Community Expert
April 4, 2007
and if the page is a repeat view what should happen after starting a random frame.
Participating Frequently
April 4, 2007
May be I did not expressed it well but this exactly what I am looking for. Only when I reload the html page, the swf should start at a random frame. If I don't reload the html page (I am still using the same page) the swf should run in a normal cycle(image1,2,3,4,5,1,2,3, ..)and so on

Hope it's clear now.
Thanks a lot again for your efforts
kglad
Community Expert
Community Expert
April 4, 2007
your first request is not the same as your 2nd request. if those two requests are part of the same issue, then you may be asking for the frames of your main timeline to play, one after the other, in a random order. is that what you want? if not, explain exactly what you want.
Participating Frequently
April 4, 2007
Thanks a lot again

This is what I did in my swf, In the first frame the main code is
this.gotoAndPlay(Math.ceil(Math.random()*this._totalframes));
What this does is whenever the turn for the first frame comes; the next frame is randomly selected.
I want this to happen whenever I reload the html page not whenever the one cycle of the image sequence is over (the turn for the first frame comes)

Thanks a lot for your time and efforts.
kglad
Community Expert
Community Expert
April 4, 2007
actually, you don't need to do anything other than use randomization code at the beginning of your swf if you're going to allow repeats.

the chances of a length 4 duplicate sequence (consisting of 4 items) being the same (if you allow repeat items) is 1/256. it's not worth storing the previous sequence and checking if the current one is the same as the previous.
Participating Frequently
April 4, 2007
Thanks alot for your time
here I mean that the next sequence that will be run should be different than the previous one seen by the same user. whenever I (as a user) reload the HTML page I should have the sequence of images run in different order.
Hope that make sense