Cycling through several Flash movies with each pageview?

Morgan19

Registered
I have six Flash movies that act as a header on a webpage and would like to randomly change which one displays each time a user visits/refreshes the page using Javascript. I've done it with static images before using this code in the header:

Code:
    <SCRIPT LANGUAGE="JavaScript">
    iArray=new Array(
    "images/photo1.jpg",
    "images/photo2.jpg",
    "images/photo3.jpg",
    "images/photo4.jpg");
    ri=Math.floor(iArray.length*Math.random());
    ri='<IMG SRC="'+ iArray[ri]+ '" BORDER=0>';
    </SCRIPT>

...and this where I want the image to be:

Code:
    <SCRIPT language="JavaScript">
    <!--
    document.write(ri);
    // -->
    </SCRIPT>

But is there something similar to that which I can use for cycling through several Flash movies?

m19
 
I would assume that it would be similar, if not almost identical, to cycling through static images -- simply build the correct HTML into the variable "ri" and use the document.write method to write the correct HTML into the page.

If there something different about the Flash movies that prevents this from working?
 
ElDiabloConCaca said:
If there something different about the Flash movies that prevents this from working?

I don't know, that's why I asked. ;) I tried swapping out the filenames (inserting the Flash files instead of images) but it didn't work. I'm just not sure what I should replace...

ri='<IMG SRC="'+ iArray[ri]+ '" BORDER=0>';

with...

m19
 
This should work:
Code:
<object width="550" height="400">
<param name="movie" value="somefilename.swf">
<embed src="somefilename.swf" width="550" height="400">
</embed>
</object>

The "object" is recognized by Explorer, and "embed" is recognized by Netscape-based browsers -- at least that's how it was in the old days. Things may have changed now -- I don't do much Flash anymore. :(

This will simply not work for people that don't have Flash Player installed, though -- more fancy code can be written that will send them to the download page for Flash Player or display a message or something.
 
But doesn't that just play one Flash movie? The whole point is to have it cycle through six or seven each time a user refreshes or revisits the page, but it doesn't look like your code would do that...

m19
 
No, it won't do that.

You could, however, create a "master" flash movie who's job is to solely load a random other flash movie and play it. Then, upon completion of the first movie, it would randomly pick another and load and play it.

That way, you have static HTML that points to the master Flash movie, which in turn simply loads random flash movies and plays them. It would require some actionscripting in Flash, but I don't think it'd be too difficult.
 
Hmm, I'll have to look into doing it that way, as it sounds like it's just about the only feasible method at this point. ;) Just wish I knew anything about actionscripting.

m19
 
ElDiabloConCaca said:
however, create a "master" flash movie who's job is to solely load a random other flash movie and play it. Then, upon completion of the first movie, it would randomly pick another and load and play it.

That way, you have static HTML that points to the master Flash movie, which in turn simply loads random flash movies and plays them. It would require some actionscripting in Flash, but I don't think it'd be too difficult.

Okay, I'm no Flash master and I haven't been able to figure out how to set up a movie that'll call to other movies, either with action scripting or otherwise. Can anyone help with that (and hopefully very quickly)?

m19
 
Back
Top