Randomize background image

  • Fred_J
  • Newbie
  • Newbie
  • Fred_J
  • Posts: 6

Post 3+ Months Ago

I have read the previous thread about "Randomize and loop multiple images", but I dont want my script to loop and change background images every x seconds. I just want it to randomize a fixed background image. Please help me!

Cheers, Fredrik
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Tchuki
  • Mastermind
  • Mastermind
  • Tchuki
  • Posts: 1774
  • Loc: Edinburgh

Post 3+ Months Ago

Go to:
http://www.kirupa.com/developer/actionscript/loading_random_movie.htm

And use the principle of that load random movie using an array to load in a random picture.

There is also a tutorial on a picture gallery in there aswell if you want to search for that.

Regards,
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Keep in mind when dynmically loading in an image, only non-progressive .jpg images have the ability to be dynamically loaded into flash. Otherwise you will have the put the image in it's own .swf file and load that in.

Also note... loadMovie() is used for both .swf and .jpg files, so the only thing that will change in the script is the file extension.
  • eslie
  • Novice
  • Novice
  • eslie
  • Posts: 21

Post 3+ Months Ago

use goto() and play() functions to randomize images
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Loading seperate movies/images in reduces file size and improves flexibility.

So while importing a bunch of images into a file, and having to orginize them all in the frames and using a gotoAndStop(random(_totalframes)+1) function will work, it's not exactly an efficient or recommended way to do something like this.
  • Abelius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 260
  • Loc: Miami Beach, FL, USA

Post 3+ Months Ago

Try this: Make an empty movieclip and put it somewhere on the stage. Give it an instance name of globeHolder_mc and then in the first frame of any layer in the main timeline, write this:

Code: [ Select ]
function loadPic() {
    var time = new Date();
    var localtime = new Date();
    localtime = localtime.getHours();
    var localtime = "" + ((localtime < 10) ? "0" : "") + localtime;
    var gmtMS = time.getTime() + (time.getTimezoneOffset() * 60000);
    var gmtTime = new Date(gmtMS);
    var hour = gmtTime.getHours();
    var offset = new Date();
    offset = offset.getTimezoneOffset() / 60;
    var str1 = "http://www.worldkit.com/images/bgmap/dec";
    var str2 = ".jpg";
    output = str1 + offset + localtime + str2;
    _root.globeHolder_mc.loadMovie(output);
    _root.globeHolder_mc._xscale = 65;
    _root.globeHolder_mc._yscale = 65;
}
loadPic();
  1. function loadPic() {
  2.     var time = new Date();
  3.     var localtime = new Date();
  4.     localtime = localtime.getHours();
  5.     var localtime = "" + ((localtime < 10) ? "0" : "") + localtime;
  6.     var gmtMS = time.getTime() + (time.getTimezoneOffset() * 60000);
  7.     var gmtTime = new Date(gmtMS);
  8.     var hour = gmtTime.getHours();
  9.     var offset = new Date();
  10.     offset = offset.getTimezoneOffset() / 60;
  11.     var str1 = "http://www.worldkit.com/images/bgmap/dec";
  12.     var str2 = ".jpg";
  13.     output = str1 + offset + localtime + str2;
  14.     _root.globeHolder_mc.loadMovie(output);
  15.     _root.globeHolder_mc._xscale = 65;
  16.     _root.globeHolder_mc._yscale = 65;
  17. }
  18. loadPic();


Just an example of loading images. Of course, you can also randomize them, but the principle is the same...
  • Fred_J
  • Newbie
  • Newbie
  • Fred_J
  • Posts: 6

Post 3+ Months Ago

Thank you for all the info. I finally solved the problem!

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 14 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.