A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Changing backround problem

  1. #1
    Junior Member
    Join Date
    Mar 2004

    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);

    and this is what happens


    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.

  2. #2
    No ambitions beyond flash ScimSlave's Avatar
    Join Date
    Sep 2002
    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
    Dulce et decorum est pro Scim mori.

  3. #3
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Los Angeles
    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:


    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

Click Here to Expand Forum to Full Width

HTML5 Development Center