I screwed up my background! Need help to fix it

Okay… so I’m working on this site and I’ve got it set so that everytime the site is visited it shows a different background image. I have three different image that rotate. Here is the code for that…

choice = Math.round(Math.random()*2)+1;
switch (choice) {
case 1 :
	location.loadMovie("homebkgd1.swf");
	break;
case 2 :
	location.loadMovie("homebkgd2.swf");
	break;
case 3 :
	location.loadMovie("homebkgd3.swf");
	break;
}

It was working just fine and then I went around and played with it and something went wrong and it won’t work anymore. I just get one image and it is 800x600. The three backgrounds are very large images so when the user drags his browser there is no white space.

Here is the link if you want to see what I’m talking about.
http://doxa.ifworld.com/test/kptest.html

I hope this makes sense.

Thanks in advance!

your code is kind of ugly i would change it to this


choice = random(3);
switch (choice) {
case 0:
	location.loadMovie("homebkgd1.swf");
	break;
case 1 :
	location.loadMovie("homebkgd2.swf");
	break;
case 2 :
	location.loadMovie("homebkgd3.swf");
	break;
default:
location.loadMovie("homebkgd1.swf");

}

No real input, but I quite like your site, simple and effective.

“location” is showing up as a reserved word in flash (for me)? I’d change that clip name to start - then, trace out the cases in the switch statement to make sure you’re getting your full range of randoms (1,2,3) - the size issue - if you’re loading onto a blank movieclip, make sure to highlight that clip and check your transform palette - it may be scaled down. I’ve down that before w/ target clips where I accidentally scale them, then loaded images or other things appear scaled.

Thanks Dreeft. The site will have a ton of content. Just trying to get a few picky things out of the way first.

Bombsledder, couldn’t get that code to work.

Creatify, I’m still a newb when it comes to AS. I’m actually surprised I got the code to work in the first place. Can you or someone else show the code to connect those three .swf’s to my blank mc “background_mc”?

Thanks everyone!!

Okay, I’ve messed with the background a bit and you can see that its not going well. The gray box in the background is supposed to be the rotating .swfs. They are also supposed to be locked to the LT but don’t stay put.

I’m also trying to set the navagation bars to stretch the window width on resize. I’m only working on the top on right now. This is the code…

Stage.scaleMode = "noScale";
sizeListener = new Object();
sizeListener.onResize = function() {
KostovBar._x = Stage.width/2
};
Stage.addListener(sizeListener);

You can see here http://doxa.ifworld.com/test/kptest.html that onresize the bar jumps to the right.

Any suggestions? Thanks!!