Loading a Random Flash Movie
Step Three: Creating the ActionScript
Important Note: Make sure that you can see Actions - Frame at the top of the Actions Panel:
The Actions Panel has Actions - Frame in the top corner.
Note: To see if Script Assist is on or off go to the Action Panel's Side Menu Button:
Script Assist is On when ticked: (remove the tick)
Cross Ref: If you are not sure what Script Assist is or how to switch it on and off see the short Tutorial: Actions Panel
// Sets the number of Flash Movies in the random sequence
// IMPORTANT: Set this number to how many Flash Movies you have
var myMovieSequence = 6;
// Creates the random number:
var myRandomNumber = Math.floor(Math.random()*myMovieSequence)+1;
// Creates the full Flash Movie name like: 1.swf
var myMovieName = myRandomNumber + ".swf";
// Loads the random Flash Movie:
Note: This will load only one of your random Flash Movies. Just to check that the random load is working test your Movie several times.
Important: In Test Mode if you have not saved your Flash file into the same folder as your Flash Movies your movie will not work. When you upload your files to the Internet then the HTML page must be in the same location as the Flash Movies and the location of the Master Flash Movie becomes irrelevant. If you want to use your Flash file in multiple web pages and load Flash Movies form one location you will need to specify an absolute address like this:
var myMovieName = "http://www.yourwebsite.com/movies/" + myRandomNumber + ".swf";
I hope you have found this useful. If so perhaps you could recommend this site to others and link to webwasp!
28633 visitors to this page since
30 Oct 07 •
Webwasp is Phil Schulz's baby. You are welcome to contact me or become my Facebook friend: Click here
All material on this site is protected under international copyright © law. DO NOT reproduce any material from this site without written permission. Please ask as permission is often granted.