-
Changing backround problem
I put this code in the first frame like one of the people that helped me before told me to
ran = math.round(math.random()*9+1);
gotoAndStop(ran);
and this is what happens
http://www.docsully.com/images/test.swf
I even added a stop(); to the end but it never loaded the other pic. Please help if you can. thank you all for your time.
-
No ambitions beyond flash
hi
try typing this instead:
Math.round( ( Math.random() * 9 ) + 1 )
( letters in uppercase )
and also try to use _root.gotoAndStop( ran );
and try to trace "ran" , this kind of **** happens when the parameter for gotoAndStop is undefined or somehow unuseable.
good luck
-i
Dulce et decorum est pro Scim mori.
-
Senior Member
There are two potential problems with your code.
1st problem:
This line:
ran = math.round(math.random()*9+1);
Will return a number from 1 to 10, but the distribution is uneven (it has 1/9 chance of returning each of the numbers from 2-9, but only a 1/18 chance of returning 1 or 10).
If you want an even distribution, then don't use Math.round(). Use either of the following instead, which are equivalent:
ran = random(10)+1; // my preference
ran = Math.floor(Math.random()*10) + 1;
Also, Math should be spelled with uppercase M.
In my opinion, the only time that Math.round() should be used is when rounding a number for a text-display that is to be read by humans.
2nd problem:
gotoAndStop(ran);
If you have a line on your first frame that jumps to another frame, there is a strong possibility that the frame you wish to jump to won't be loaded yet. You'll need a preloader to insure all the frames are loaded, or at least the frame you wish to jump to is loaded.
The preloader doesn't necessarily need once of those fancy preloader animations - you just need to wait until the frames are loaded.
Last edited by jbum; 05-04-2004 at 01:50 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|