-
Senior Member
Random load of external SWF's
I'm using Flash CS3. Web site in question with Flash issue is here:
http://beta2.977theriver.com/ Look at the top of the page in the Masthead.
I have a series of external SWF's that load into a main SWF randomly, then dissapear and the next random SWF loads. It works fine for a while, but if you stay on the page for a couple minutes, then whatever the last random SWF was, starts to repeat, rather than another random SWF loading. I need the SWF's to randomly appear no matter how long someome stays on the page.
The code I'm using is below. Thanks for any help.
randomClips = new Array ("/Flash/ACDC.swf", "/Flash/Aerosmith.swf", "/Flash/Boston.swf", "/Flash/Doors.swf", "/Flash/Doobies.swf", "/Flash/Halen.swf", "/Flash/Journey.swf", "/Flash/LedZep1.swf", "/Flash/PinkFloyd1.swf", "/Flash/Skynard.swf", "/Flash/Stones.swf");
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
target_mc.onEnterFrame = function() {
if (this._currentframe == this._totalframes) {
delete this.onEnterFrame;
_root.randomBackground();
}
}
}
function randomBackground() {
if (playedClips.length>3) {
randomClips.push(playedClips.shift());
}
randomNumber = random(randomClips.length);
randomClipsLoader.loadClip(randomClips[randomNumber], _root.mtClip);
playedClips.push(randomClips[randomNumber]);
randomClips.splice(randomNumber,1);
}
var randomClipsLoader :MovieClipLoader = new MovieClipLoader();
randomClipsLoader.addListener(mclListener);
randomBackground();
-
Code:
var playedClips = new Array();
var randomClips = new Array("media/1.swf", "media/2.swf", "media/3.swf", "media/4.swf", "media/5.swf");
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
target_mc.onEnterFrame = function() {
if (this._currentframe == this._totalframes) {
delete this.onEnterFrame;
_root.randomBackground();
}
};
};
function randomBackground() {
if (playedClips.length > 3) {
randomClips.push(playedClips.shift());
}
var randomNumber = random(randomClips.length);
randomClipsLoader.loadClip(randomClips[randomNumber],_root.mtClip);
playedClips.push(randomClips[randomNumber]);
randomClips.splice(randomNumber,1);
}
var randomClipsLoader:MovieClipLoader = new MovieClipLoader();
randomClipsLoader.addListener(mclListener);
randomBackground();
-
Senior Member
That worked perfectly! Thank you very much
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|