View Full Version : Random frame: To display background
chockybickyman
October 8th, 2004, 10:40 PM
I have a movie clip placed on the first frame within the main timeline.
- The movie clip contains 4 frames, each frame has a different image.
- I want to display one of these frames at random every time the game loads.
- What script would i need to target a random frame within this movieclip?
- Would this script be placed on the main timeline?
Any help, much appreciated
Cheers
Peter.D
chockybickyman@hotmail.com
Yeldarb
October 8th, 2004, 10:43 PM
randFrame = random(3)+1;
yourMovieclip.gotoAndStop(randFrame);
chockybickyman
October 8th, 2004, 10:53 PM
Couldn't get it to work!!!
Is this script applied to the movieclip, or the onclipEvent?
Where is this script applied?
chockybickyman
October 8th, 2004, 10:58 PM
Alrite i got the function to work:
1 small problem: The game loads a random frame now, but keeps scrolling through frames rather than goin to a random frame than and stopping.
Any ideas as to why this happening?
Cheers
Peter.D
Yeldarb
October 8th, 2004, 11:01 PM
Put a stop(); on each frame in there.
chockybickyman
October 8th, 2004, 11:12 PM
Yep did that, didnt stop the random generation at all.
Anymore suggestions??
Perhaps you could make a flash file for me showing the working file, coz it doesnt seem to work.
Is there any other scripts you could recommend, say picking from the 4 movie clips in the library when movie loads.
create a function called bgGraphics
and load these 4 clips at random, bg1, bg2, bg3, bg4
Cheers
Peter.D
chockybickyman@hotmail.com
Yeldarb
October 8th, 2004, 11:20 PM
OH wait, you're saying that the file keeps generating a new frame and going to it? I thought you meant that the movieclip that had the frames just kept playing.
No, I won't make a flash file for you.
Try putting it in an onLoad so it only executes once.
chockybickyman
October 8th, 2004, 11:24 PM
Yep, thats cool, working fine now.
Thanks for your help.
Cheers
Peter.D
chockybickyman@hotmail.com
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.