dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Random Image Insert

  1. #1
    Senior Member
    Join Date
    Aug 2004
    Posts
    130

    Random Image Insert

    Hello,

    I am trying to create a placeholder on my flash page that will import images randomly from a file. Basically on my page I would like to have a box that will display jpegs randomly from a file. Can someone point me in the right direction as to how I can accompish this? Thank you.

  2. #2
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    Code:
    randomClips = new Array ("background0.jpg", "background1.jpg", "background2.jpg", "background3.jpg");
    function randomBackground() {
    	randomNumber = random (randomClips.length);
    	_root.mtClip.loadMovie (randomClips[randomNumber]);
    }
    randomBackground();
    Put that in a frame. When the movie loads or reloads, it will show a random picture. The more jpg's in the array, the more random it will be.

  3. #3
    Senior Member
    Join Date
    Aug 2004
    Posts
    130
    Thank you

  4. #4
    Senior Member
    Join Date
    Aug 2004
    Posts
    130
    Is there a way to reference the jpg's from a file rather than hard coding them? I would like to be able to use the same code in multiple swf's and add/remove the images from one location (file) rather than going into each swf and changing the code each time I want to add or remove a picture. Thank you.

  5. #5
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    I don't know of an easy way, but I'm sure there is one. Ask in the actionscript forum.

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