Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / General Flash Topics / July 2008



Tip: Looking for answers? Try searching our database.

Inserting Random Background Images

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sally Donaldson - 20 Jul 2008 16:48 GMT
Hi

Can someone please please help me.  I have a very simple Flash movie where I
want to insert a random background image every time the movie plays or the
web page is refreshed.

I found the following script online but need a step by step idiot¹s guide
how to add it to the original Flash file.

randomClips = new Array ("background0.jpg", "background1.jpg",
"background2.jpg", "background3.jpg");
function randomBackground() {
randomNumber = random (randomClips.length);
_root.mtClip.loadMovie (randomClips[randomNumber]);
}
randomBackground();

Cheers

Sally
Noelbaland - 21 Jul 2008 03:37 GMT
Hello,

Follow these steps

1) In the timeline rename Layer 1 to Actions. Click on the first frame and hit
F9 on your keyboard or go to Windows>Actions.  Copy and paste the code above
into the Actions Panel.

2) Create a new layer and name it Background.  Drag the layer under the
Actions layer.  Go to Insert>New Symbol.  In the Create New Symbol box that
appears, choose Movieclip for Type and give it a Name (bkg_mc will suffice for
now).  Click OK to close. You will now be inside the bkg_mc timeline.  Click on
either the Scene 1 link or the back arrow to go back to the Main stage.

3) If it hasn't been done yet, make sure your stage size is the same as the
background JPG images you're going to use.   Go into the Library and drag the
bkg_mc onto the stage.  In the Properties panel, give your movieclip an
Instance name of mtClip.  While still in the Properties panel set the X and Y
to 0.

So what you've done is created an empty Movieclip symbol and placed it on the
stage.  This Movieclip symbol has been given the instance name of mtClip (which
is referred to in the script) and placed in the top left corner of the Main
stage.  This is the clip thats going to load your background JPGs.

Save your movie in the same folder as the background JPG's your going to use
and then go to Control>Test Movie to preview your movie.  If all went well you
should see a different background everytime you preview your movie.

Hope that helps
Sally Donaldson - 21 Jul 2008 11:27 GMT
Hi

Many many thanks.  This is practically the same as Rob from Action Script
Group suggested.   You are  both geniuses!!!  I didn¹t though alter the size
of the stage as I have an existing movie.

Thanks again,

Take care

With kind regards

Sally
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.