Avoid Math.random() from looping the same number twice?

I'm trying to play a random gallary image by making it stops at different frame every few seconds, and the actions is completely random.
The problem is, since there are only 5 different images(5 frames) I'm displaying, there is a high probability that it stays at the same frame, how do I avoid that? Like avoid staying at the same page twice, if not run the function again....?
setInterval(createItems,throwItems);
var RandomImg:randomImg =new randomImg();
RandomImg.y=100;
RandomImg.x=180;
RandomImg.gotoAndStop(Math.floor(Math.random()*(1+5-1))+1);//generate random value between 1-5
addChild(RandomImg);
Thanks

How do I keep track of the random value, like what value should I put within the if to compare?
I try modify it a little, and wrap it within an if(), and use preValue to track down the previous frame, am I doing it right?
setInterval(createItems,throwItems);
var preValue:Number;
function createItems():void
     var RandomImg:randomImg =new randomImg();
     var randomFrame= Math.floor(Math.random()*(1+5-1))+1; //generate random value between 1-5
     RandomImg.y=100;
     RandomImg.x=180;
     RandomImg.gotoAndStop(randomFrame);
     if(preValue == randomFrame)
          RandomImg.gotoAndStop(Math.floor(Math.random()*(1+5-1))+1);
          addChild(RandomImg);
          preValue = randomFrame;
     }else
                    addChild(RandomImg);
                    preValue = randomFrame;

Similar Messages

  • How do I stop mail from looping the same emails into inbox?

    How do I stop mail from looping the same emails into the inbox over and over again? It does the same thing with deleted messages that keep showing up again and again in multiples even after deleting them. I have made sure my server settings in all email accounts are set to delete immediately once I delete them on my MacBook Pro/IPhone. This issue has severely compromised the efficiency of Mail on my MacBook. Thanks for any help you're able to give me.

    I have tried that but it does not fix the problem.
    The "card" group is not a previous recipient.
    Although not available for editing in Contacts, it is a valid group showing up in the "To" field of Messages, Mail, or any app using the AddressBook.
    Its associated file is automatically created in:
    ~/Library/ApplicationSupport/AddressBook/Sources/<hexaFolder>/MetaData/<hexa>ABG roup.abcdg
    This is why it also shows up in the Spotlight results...
    If I manually remove this file, it gets recreated...
    If I turn off the syncing through iCloud, the entry gets deleted. If I turn it up, it comes back!

  • I keep getting calls from non existing area codes and phone numbers.  They are never the same number twice.  How do I stop this?

    About a week ago I started getting phone calls on my cell phone from numbers that do not exist, including the area codes.  I can not report these to the Do Not Call list because the area code is non existent.  I'm getting these calls all the time now and never from the same number twice so there's no point in blocking them.  If I answer I may or may not get a person who has an accent from India so heavy that I can't understand what they are saying.  This is getting to the point where I just want to cry I'm so frustrated.  Anyone else having this issue or does anyone know how to stop it?
    Thank you

    I'm sorry that you are having all these troubles. I have sent you a private message.
    Anthony_VZ
    **If someones post has helped you, please acknowledge their assistance by clicking the red thumbs up button to give them Kudos. If you are the original poster and any response gave you your answer, please mark the post that had the answer as the solution**
    Notice: Content posted by Verizon employees is meant to be informational and does not supersede or change the Verizon Forums User Guidelines or Terms or Service, or your Customer Agreement Terms and Conditions or plan

  • Double contacts as "iPhone"...my phone saves the same number twice, once with a 1 before the area code and one without it. It causes two different threads in my texts even of they're saved as the same contact

    my phone saves the same number twice, once with a 1 before the area code and one without it. It causes two different threads in my texts even of they're saved as the same contact

    My wife is having the same problems as a reciever. She works in a school as a teaching assistant and her teacher sends messages that are mixed with previous texts from ages ago.
    Can anyone shed some light on this problem or is it only her and this poster?
    2m42s

  • User Exit For VA01 To Restrict From Entering The Same Material twice

    Hello All,
    I have a requirement that in sales order creation(VA01) i want to restrict From entering the same material
    more than once in a sales order  i.e more than one same material not allowed in sales order i have tried alot of user exists but of no use
    can u tell me the exact user exit
    Regard's,
    Mahesh Dasari

    Hi Mahesh Dasari,
    1.This user exit is used to add additional datat to VBAP struture like custom fields. And this user exit is called for every single line item when processed.Say you have 10 items then this user exit will be triggered before each entry is populated in the XVBAP.
    2.When the user enters item 10 with material 1 we allow him, then for the next line item say 20 we check if the material entered or processed ( this will be available in VBAP structure ) is available in XVBAP and  the line item 10 is not deleted.
    3. If the above check  true then it means that the material entered is already existing else its not so it will proceed to next line item
    e.g. in your question , item 10- Mat1 , item-20- Mat12, item-90-Mat1,
    Then as per the code I have given , item 90 will be deleted or removed.
    4. Now you can either delete the line item by clearing VBAP as I have done or give a error message  that will be as per your requirement.
    Use the logic I have provided in my earlier post , and see the behaviour.
    Hope you find this answer helpful and set this questions answerd
    Regards
    Arun Thiyagarajan

  • SOS SOS !!The Program Asks me the same number twice

    I am trying to do the exercise 5.11 from Java Deitel 4th edition it says
    "Write an applet that reads five numbers, each between 1 and 30. For each number read, your program should draw a line containing that number of adjacent asterisks. For example, if your program reads the number 7, it should display *******."
    This is my code:
    // Java core packages
    import java.awt.Graphics;
    // java extension packages
    import javax.swing.*;
    public class Exe5_11 extends JApplet {
         public void paint( Graphics g )
    int number;
    String input;
         super.paint( g );
    JTextArea outputTextArea = new JTextArea();
    outputTextArea.setText("Hystograms\n\n");
         for ( int i = 1; i <= 5; i++ ) {
    number = 0;
    while ( number > 30 || number < 1) {
    input = JOptionPane.showInputDialog("Enter Number " + i );
    // convert user's input to an int
    number = Integer.parseInt( input );
    } // end while input
    // display asterisks
    for ( int j =1; j <= number; j++) {
    outputTextArea.append ("*");
    outputTextArea.append ("\n");
    } // end for
    JOptionPane.showMessageDialog( null, outputTextArea,"Hystograms", JOptionPane.INFORMATION_MESSAGE );
    System.exit(0);
    } // end paint method
    } // end class Exe5_11
    The problem:
    The program asks me twice for the first number I don't know why? The logic is good, I think is something related with the scope of the variables or something particular with Java I don't know jet.
    Please help me, I have spent 2 hours in this exercise.
    THANK YOU IN ADVANTAGE!!
    Samuel

    double-post

  • Outgoing call log shows calls from my own number to the same number

    Every so often, I pick up the phone to dial out and get a fast busy tone.  I hang up, wait a few seconds, and try again, and I have dial tone and can dial out.
    I have not noticed any pattern or timeframes when this occurs.
    When looking at my online call log, I see calls at very random and arbitrary times of the day in the Outgoing column from my own number and TO the same number.  ALWAYS after that there is an entry that the call went to voice mail.  There is never an actual voice mail message, of course; I guess it hangs up before VM detects a valid message.
    There appears to be an entry like this every single day, but, again, at very different times and with no discernible pattern.
    Why is my own phone number trying to dial out to itself and at various times of day and night? 

    Having the same issue. Calls being made FROM my Maryland home landline TO a Virginia number.
    I tried calling the number from my office phone, but it goes straight to an unoccupied voicemail.
    When I first called about it, the Verizon representative also reassured me there was no charge for these calls, but that is not the issue. The issue is that someone or some machine has access to my home landline and it is making these calls. She was pretty insistent that it must be someone in my home, but much like others have stated, the records show that calls are made when no one is home, or when we are all home watching TV in the living room. We have one phone in the kitchen, so there are no secret calls being made. And certainly not 20+ times a month.
    The first representative transferred me to another tech. At first, the new tech dismissed the idea that there could be cross-wiring (what the first tech suggested) because it's over the internet. There are no physical wires to cross.
    The tech eventually ran a test and determined there was a "short bound in the wiring," so she said she was going to "reboot the ONC." I don't know what any of that means.
    The test came back successful, and she was able to block the number (inbound and outbound).
    I told both techs that this problem is not unique to my account; that there are several people on Verizon forums reporting the same issue.
    She was not able to explain why, so we are no closer to figuring this out.
    All I can recommend is calling Verizon tech support and having the number blocked. We'll see what happens with the next bill.
    Also, if it's worth typing out, make sure you're reviewing your bills from Verizon. I've had to call at least five times in the 4.5 months about one thing or another.

  • Iphone sms separated from the same number....?

    Hi guys, i dont know why this happened but my text messages are separated from each other even though it has the same number, why?
    Its 2 different threads with the same number which one of the text messages are the one i sent and the other is one i recieved. This happened when i restored my sms to my iphone.
    I've looked into it and i also found out that when i open ibackupbot and view my text messages there i found that one of the sms has an + at the beginning like +44 and then the number, and the other just begins like 0044 and this is the same contact/person... can that be the problem?
    Otherwise please help!!

    Delete the text that's messed up. It happens sometimes. Suck it up and move on. Really, there is no known or supported way to merge messages.
    That is why I recommended a full SMS archive that way you can delete the broken stuff from the phone and move forward with a clean slate while still having an on-demand reference.
    Put them in a PDF in iBooks and you will be able to access all of your old messages. Boom! Case closed.

  • I currently have aT-Mobile sim, and therefore, a UK telephone number. Can I get a sim from EE with the same number to use in my iphone 5?

    I currently have aT-Mobile sim, and therefore, a UK telephone number. Can I get a sim from EE with the same number to use in my iphone 5?

    The easiest way to find out what carrier it's locked to would be to call the store where you purchased the phone.
    The phone can be unlocked from any location.  However, most carrier have restrictions about unlocking and you have to contact them for details.

  • I cant call to a mobile number since yesterday, but can receive call from the same number. I am using iphone 4s. Is there any setting error?

    I can't call to a mobile number since yesterday, but still can receive call from the same number. I am using iphone 4s. Is there any setting error?

    you have to make sure that CFWD Bridge Mode under the Line tab of the SPA9000 where the SPA400 is registered is set to ALL...include VMSP Bridge and XFER Bridge Mode as well..power cycle then check if you are still getting one-way audio
    | isolate! isolate! isolate! |

  • Somehow a random number appeared on the bottom of all my slides on keynote- it is always the same number regardless of the slide number I am- how can I remove it??

    Somehow a random number (white font on black square) appeared on the bottom of all my slides on keynote… it is always the same number regardless of the slide number I am… how can I remove it??

    Sorry!  I hope I didn't waste anybody's time.  I should have looked first for previous posts and I would have seen other people having the same issue and how they solved it.  Problem solved.  Thanks

  • Random Number being changed to the same number for all rows

    hello all,
    first of all I want to mention that this problem start happening after 2.14 instalation of Power Query.
    I'm creating new column in my query and setting all values to random numbers. The problem is that next step (doesn't matter what it do itself) somehow changes all those random numbers to the same random number for all lines.
    here's code sample:
    InsertedCustom = Table.AddColumn(RemovedColumns3, "Random Number", each Number.Random()),
        InsertedCustom2 = Table.AddColumn(InsertedCustom, "Analyst Full Name", each [Analyst First Name]&" "&[Analyst Last Name]),
    when I'm checking step by step, InsertedCustom  creates new column and all values are being set randomly for all lines BUT when going to the next step (InsertedCustom2) all values in the column "Random Number" are being changed to the
    same number (no matter that InsertedCustom2 itself should not be doing anything to column named "Random Number") . I even tried moving InsertedCustom step to the bottom of my code but it didn't help and still facing this issue.
    p.s. updated my PQ to 2.15 - didn't help

    This is a known issue. Power Query assumes that functions are idempotent (given the same arguments, they produce the same result), which isn't true for Number.Random. Our optimization pipeline is turning Number.Random() into a constant in the scenario you
    encountered, which results in all rows having the same value.
    There's been some discussion of how to fix this, but that won't help you in the near term. Can you describe a bit more about your scenario and what you're trying to accomplish? Perhaps we can help you find a workaround.
    Ehren

  • We have a 5s active on our account.  After turning on a previously active 4s (it had the same number)  The 5s can no longer place call and when you call it from another phone the 4s rings, but will not pick up.  Texting over the cell networks works fine.

    We have a 5s active on our account.  After turning on a previously active 4s (it had the same number)  The 5s can no longer place call and when you call it from another phone the 4s rings, but will not pick up.  Texting over the cell networks works fine.  Any suggestions??

    hens0861,
    Hmm, let's ensure this is working as it should be! So what phone should be active on your account? Did you switch the devices online or how to did you activate the 5s? Please share details.
    KarenC_VZW
    Follow us on Twitter @VZWSupport

  • My i phone got stolen and i got a new one with the same number but how do i synch it up with my old contacts?  i thought i could do from ituned but it hasnt worked!!

    hello,
    my i phone got stolen and i got a new one with the same number, but i cant get it to synch up with my itunes to make it like my old phone! can you please tell me how i do this. i need all my contacts and content etc etc.

    Plug it into iTunes and tell iTunes what to sync to the device.

  • Do i have to store multiple variations of the SAME number for caller id to work properly?

    i am in trinidad and tobago, using the TSTT/bmobile network. i have a brand new factory unlocked iphone4 from the UK.
    all my contacts are stored as +1868XXXXXXX.
    with sms, i get the name matched to caller id.
    with calls however i'm having a problem. carriers in my country send the caller id for incoming calls randomly in several different formats (+1868XXXXXXX; 1868XXXXXXX, 868XXXXXXX; or XXXXXXX).
    does this mean that i must have all four variotions of the same number saved for EACH contact???
    why doesn't the iphone match the numbers backwards like almost EVERY other phone that i have owned in the past?
    is there no other solution to this problem? from what is posted in the article below, it seems like only solution #4 works:
    http://support.apple.com/kb/TS2326
    i've read that there is a 'jailbreak fix'. i don't even know what jailbreaking means, but is that the only option that i have to explore?
    this is a SERIOUS shortcoming of this phone. has anyone found any other solution to this problem?

    jasonnPOS,
    you seam to have had the exat same problem I am having now. Have you solved it?
    The link you send in your post :
    http://support.apple.com/kb/TS2326
    As I think you already noticed doesn't solve the problem it merly duplicates the numbers in each contact. One with +and country code and one without that...
    There has to be another solution...

Maybe you are looking for

  • How to get a pulse in a specified sampletime

    Hi. We are making a LabVIEW program to communicate with PumpWorks through DDE, and have established communication. The problem we can't find a solution to is this: We want to start the pump (TRUE) and stop (FALSE) it in LabVIEW. PumpWorks can only re

  • Print on cardstock HP deskjet F4400

    wanting to print on cardstock, adjusted paper to matte cardstock setting, cardstock rolls through printer but doesn't print on it.

  • Unable to load function storage while opening MM

    Hi All,   I am eporting the design object from development to a completely new different server. i used to get all the object in place other than the MMAPPING. when i open the MM , i faced an error showing "Unable to load function storage"" Can anone

  • Nikon D7000 .nef files

    I have a Nikon D7000 camera which creates raw files - .nef and my version of CS5 is not able to open them directly. Does the latest version of CS5 resolve this problem?

  • Aggregate Function application

    Dear Readers, Just a logical observation/question: How does SQL server know  what to count in the query below: I didn't specify count(customers.lastname) as 'NamesCount'. However I get the correct result. Is there a certain order that the SQL follows