Random Background Tutorial PROBLEM!

Hi there,

i have followed the Kirupa tutorial for the random bacground image, and it works fine…but not for my liking!!

Basically the tutorial loads up external .swf’s that have embedded pics within them…

choice = Math.round(Math.random()*5);
switch (choice) {
case 0 :
location.loadMovie(“image0.swf”);
break;
case 1 :
location.loadMovie(“image1.swf”);
break;
case 2 :
location.loadMovie(“image2.swf”);
break;
case 3 :
location.loadMovie(“image3.swf”);
break;
case 4 :
location.loadMovie(“image4.swf”);
break;
case 5 :
location.loadMovie(“image5.swf”);
break;
}

  • the problem is it forces the .swf’s with the pictures to load causing the .swf’s poping on at the wrong time!! :smirk:

now my question is, is it possible to elliminate the swfs having to load and instead having it done this way:…

choice = Math.round(Math.random()*5);
switch (choice) {
case 0 :
location.gotoAndPlay(2);
break;

for instance having the picture placed at frame 2??

In conclusion, is it possible to do this effect internally instead of externally?? :thumb:

thnx in advance !! =)

*Originally posted by balroo *

  • the problem is it forces the .swf’s with the pictures to load causing the .swf’s poping on at the wrong time!! :smirk:
    **

i’m not sure what you mean here :-, do you not want the swfs to load when you load the page or something?

And i think i know what you meant by the internal stuff, you just put each image on its frame with a stop sign. Then use gotoAndPlay() instead of loadMovie. It should work…:slight_smile:

Hi there Blah!!

thnx for that, ill give it a try… i thought it would be something along that line…just need to know from other peoples perspective!! :beam: :sigh:

thnx again :thumb:

Bye 4 now !! =)

choice = random(6) ; // returns an integer between 0 and 5
theClip.gotoAndStop ( choice ) ;

Something like that?

thnx for the reply Ilyas, ill give that a try aswell!!

Bye 4 Now !! :beam:

Hi there Ilyas,

i just wondered if it is possible for you to help me out here, with this code you gave me to try,…

choice = random(6) ; // returns an integer between 0 and 5
theClip.gotoAndStop ( choice ) ;

im having a bit of trouble putting it together, could you give me a quick example of hoew to construct the code with a range of images, like:

image1
image2
image3

i would really appreciate it !! im having great problems with it!

thnx in advance!! :beam:

Balroo, i’m not ilyas and i don’t have much time to make an fla for you :stuck_out_tongue: but its really easy…all you have to do is:

if you have 3 images, make 3 keyframes on frame 1, 2, 3.

Then on each keyframe, put one image.

Then make a new movieclip, and give it the instance name theClip.

And in the first keyframe, place the code ilyas gave you. I hope that is clear!

hi blah de blah…i think ive got it now…

the old brain wasnt working there for a minute lol :beam:

i knew it was easy enough!!

thnx anywayz :thumb:

bye 4 now !! :beam: