A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: randomly loaded jpeg's

  1. #1
    Senior Member
    Join Date
    Jan 2002
    Posts
    104

    randomly loaded jpeg's

    I'm sure this is covered somewhere here but, can someone tell me how or where to get instructions on having a different jpeg load into my flash movie each time the site is visited? Like, for a different background photo whenever someone revisits the site.

    Thanks,
    dixter

  2. #2
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    The pics have to be named and numbered in sequence, starting with '0'. It would be better if you made the jpg's into swf's, but I think this would work for jpg's in MX. You also have to have an empty movie clip at the top left corner of the stage, on the lowest level. Give it an instance name of 'background'.

    On the first frame of the actions layer, add:

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

  3. #3
    Senior Member
    Join Date
    Jan 2002
    Posts
    104
    Awesome! Thanks tons!
    dixter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center