Random in AS3...when is Math.floor necessary?

Hi, I'm trying to convert:
_root.character_splash_mc.loadMovie("swfs/splashes/character_splash_" + random(3) + ".swf"); 
To the following AS3 code:
var character_splash_loader:Loader = new Loader ();
character_splash_loader.load(new URLRequest("swfs/splashes/character_splash_" + Math.floor(Math.random()*3) + ".swf")); 
MovieClip(root).character_splash_mc.addChild(character_splash_loader);
Will "Math.floor(Math.random()*3)" return the same random type of number as "random(3)"??
Thank you
(very sorry about this being so basic...trying to learn AS3 ASAP...very grateful)

Math.floor(Math.random()*3) will produce 0,1,2 as outputs, which I believe is what random(3) would do.

Similar Messages

  • Preloader not working in AS3 when viewing in a browser

    Hi there, It's me again Ysong.
    I have a problem regarding PRELOADING.
    MY TIMELINE:
    • First frame -- dynamic text which is my preloader with AS3 in it. NO MORE OBJECT in the frame only text which is dynamic.
         stop();
         loaderInfo.addEventListener(ProgressEvent.PROGRESS, updatePreloader);
         function updatePreloader(evtObj:ProgressEvent):void
              var percent:Number = Math.floor((evtObj.bytesLoaded*100)/evtObj.bytesTotal);
              myLoadText.text = "Loading..." + percent+"%";
              if (percent==100){
                        nextFrame();
    • Second frame -- the whole site in MOVIE CLIP which will be loaded after the preloading ends.
    ***The whole SWF file is only 600KB when publishing.
    ***When simulating download the preloader is working.
    MY PROBLEM:
    Whenever I uploaded these two files: (1) index.swf and (2) index.html, the preloader doesn't work. When viewed in browser it apprears to be white screen. After a couple of minutes, the index.swf appears and the preloader is not appearing as it should be. With (2), I didn't change anything on Dreamweaver just upload the file published by Flash Professional CS4.
    WHAT IS THE PROBLEM? Can anyone help me with this. I've uploaded (PUT) the files through Dreamweaver with a testing server configured.
    Thank you & Regards,
    YSONG

    hi Ned,
    I currently downloading the tutorial link you posted.
    Do you have any idea what is really happening? Because I really wanted to have a loading text only before the whole site is loaded. The SIMULATED DOWNLOAD in Flash CS4 is working great but whenever copy it in my hosting server and view it in my browser the preloader is not working.
    Thank you for your immediate response.
    Regards,
    YSONG

  • Random generate numbers when pdf opens

    I have been trying to write a script which generates a random 12 digit number when the pdf opens.  I need to the number to show up in a certain read only field on the pdf.  I have tried writing the script in the document script and have been unsuccessful.  (The random number and another part of the the document will be used to pull information from it at a later date.)  Can anyone help me with a script so that I can make this possible?

    Do you want a new random number each time the file is opened? If so, enter
    this code as a document-level script (not inside a function!):
    this.getField("fieldname").value =
    Math.floor(Math.random()*Math.pow(10,12));

  • Using Math.floor

    When I use Math.floor I get an integer part of a double rigth?
    For exemple >> If I have
    double num = 34.54
    Math.floor(num) will return 34 rigth?
    But this 34 is a double 34.0 or is an integer 34?
    If not an integer, how can I do to get the integer part "34" like a integer number 34 and not like a double 34.0?

    Yes I already did it but it is not working
    Here is the code
    private void confirm(Double list[]){
            int nParcelas = (int)(list[2]);.....
    I call the function confirm from another class, and I pass a list like parameter.
    I have the same fuction but is a list of String and work ok. I get the numbers of this list and make some operations and averything works find...
    But I want to get an item of this list and get its integer part, and it it's not working....

  • Firefox crashes at completely random times, sometimes when I have tons of tabs open, sometimes when I have just one open. Also, Vista tells me "Firefox has stopped working" every time that I close it. This started about 3 days ago.

    It happens completely randomly. Also, when I tried wearing a persona recently, it crashed after 10 seconds. The browser still crashes when I don't wear it.
    == Crash ID(s) ==
    bp-28c36c66-011e-43ce-83bb-952772100709, 464b94d3-c280-4b06-b248-9e4039159a36, a26556d9-5bf7-4984-8b12-1fdedeb516e7, 464b94d3-c280-4b06-b248-9e4039159a36, bp-86ff3df7-03e4-479c-b1c3-c14332100715

    It happens completely randomly. Also, when I tried wearing a persona recently, it crashed after 10 seconds. The browser still crashes when I don't wear it.
    == Crash ID(s) ==
    bp-28c36c66-011e-43ce-83bb-952772100709, 464b94d3-c280-4b06-b248-9e4039159a36, a26556d9-5bf7-4984-8b12-1fdedeb516e7, 464b94d3-c280-4b06-b248-9e4039159a36, bp-86ff3df7-03e4-479c-b1c3-c14332100715

  • PM: Printing Task List Attachments When printing Shop Floor Papers

    Hi,
    We have PDF documents attached to our PM Task Lists. My requirement is to print out these PDF attachments when the shop floor papers (ie Maintenance Pick List) print. I am able to determine each of the files and their paths attached to the task list, but as of yet, I am unable to automatically print them. Can anyone point me in the right direction?
    Also note that using OLE to print the attachments seperately is not an option - The reason for this is that the shop floor papers would go to the SAP Spooler and the attachments would go to the network print server.
    Thanks!
    Scott

    In transaction OPK8, in forms uncheck the 'New List' check box for the List.
    Regards
    Ramanujan

  • HT201401 my iPhone 5 randomly switched itself when somebody was calling me and now won't turn on. it had 90% battery, I've tried factory reset, connecting to iTunes and nothing works. the phone is approx 18 months old so surprise surprise out of warranty.

    my iPhone 5 randomly switched itself when somebody was calling me and now won't turn on. it had 90% battery, I've tried factory reset, connecting to iTunes and nothing works. the phone is approx 18 months old so surprise surprise out of warranty.

    My 5S just started doing this on Thursday: every fraction of a second or so it oscillates between connecting and disconnecting with the charger (USB or wall, doesn't matter). Since it's still under the limited warrantee, I took it to the local Mac dealer (I live in a small town w/out an Apple store) and they shipped it off. I'm waiting now for the replacement--telephonless, too!
    What concerns me is that many people seem to be having this issue.
    You were right to be suspicious of the Apple store employees. Once they replicated the behavior that you experienced, they should have immediatly offered to exchange your phone. Anything else, in my opinion, is unacceptable. As long as your phone is still doing it, I'd go back, ask for the manager and tell them to exchange your phone.

  • Hey guys ive got issues with my macbook pro that i bought not a year ago, and for the last week its just randomly restarting especially when im watching a video or using finalcut pro x can someone help me?

    hey guys ive got issues with my macbook pro that i bought not a year ago, and for the last week its just randomly restarting especially when im watching a video or using finalcut pro x can someone help me?

    What do you mean "Leave them my laptop again"? do you mean you have had it worked on before? for the same problem or a different one?
    You need to take it in to Apple ASAP. No matter how long they have it, you want it fixed and fixed correctly.
    top_cheese_1 wrote:
    i bought it june 2012.. still on the warranty. i just didnt wanted to leave them my laptop again, but ok if you think thats what i should do..

  • When working mouse will randomly move even when I'm not moving it

    When working on my computer my mouse will randomly move even when I'm not moving it. It is like I have a ghost mouse that is moving across the screen by itself. I checked and made sure screen sharing isn't on. It occurs randomly from what I can tell. It happened twice tonight where I'm on a window with my hand on the mouse and the cursor will move up to the top of the screen and then to the very left (which will turn on my screen saver). I will make me feel better if someone has seen this to. It happens very quickly and I can get control of my mouse. I have seen this off and on for a while. Anyone else?

    I have the same issue.
    It is a wired Mighty Mouse on a 24" iMac. My Macbook Pro with Wireless Mighty Mouse has never had an issue that I can recall, only the desktop.
    It's pretty **** annoying to be fencing something in on Photoshop and suddenly your mouse is up in the corner of the screen and you've selected half your picture.
    Anyone have any thoughts? What are the common denominators here?
    As I said, 24" iMac running 10.5.5(although it has been happening since I purchased the computer somewhere around 10.5.3) Corded Mighty Mouse, Aluminum Keyboard. Can't think of any other relevant information....

  • I'm getting a random beep sound when I hit the input button to record a turntable

    I'm getting a random beep sound when I hit the input button to record a turntable & mixer plugged into the mbox thats bleeding into the recording. How can I stop this? Please help me. It's happening if I'm recording or not, as soon as I hit the (I) input it beeps randomly.

    Thanks Jim,
    Seems to be this song. Other projects don't have this issue.
    I even took and opened the project on another computer, bounced it again and got the same "click" at the same 13 second area.
    I've bounced each track solo, listened and NO click at the 13 sec. mark
    No third party plug-ins.
    The click doesn't land close to any beginning or end of a region.
    Final mix down looks good, no peaking over 0db.
    This is making me nuts!

  • Cursor randomly jumps backwards when typing sentence

    How can I find solution to the cursor randomly jumping backwards when typing a sentence... I end up with my name is Chris and I haven typing a sentence this trouble whe
    == This happened ==
    A few times a week

    Is this happening on specific sites or totally at random?
    Also you might want to check your keyboard - may sound a bit silly, but I tried that myself on a friends laptop and we found a tiny bit of metal under the left arrow key.

  • My iPad randomly dies and when it reboots the date comes up as 1st January at 10pm?

    My iPad randomly dies and when it reboots the date comes up as 1st January at 10pm?

    Hello zoeeeeee,
    Thanks for the question, that definitely sounds frustrating.
    This may be a good opportunity to restore the iOS software that is running on your iPad. The following article outlines how to do so:
    iTunes: Restoring iOS software
    http://support.apple.com/kb/HT1414
    Thanks,
    Matt M.

  • Audigy 2 Value randomly pops/clicks when the computer is just idling.

    EAudigy 2 Value randomly pops/clicks when the computer is just idling.; I can't figure out why the I hear random popping and clicking when I'm doing absolutely nothing to the computer. Typing this right now doesn't seem to cause any popping. It usually happens when I'm not really doing anything to my computer. This was happening with Creative's drivers and software so I switched to kX drivers, but that didn't help. When I first got my computer (Asus A7N8X-E Deluxe) and got the Audigy 2, I had no problem with Creative's software/drivers at the time, no popping had occur until I installed an SATA HD. PCI latency tool helped at the time. Then I had to go through a reformat and after the reinstallation of Windows XP, the popping started occuring randomly. After my motherboard supposely didn't want to POST anymore, I bought another one which was the Epox. And same problem occured even though I reformat and reinstalled windows.
    Right now, the only thing I could think of that the SATA HD and Sound Blaster cards don't mix well together. But none of these are sharing resources. I did not want to try decrease any hardware acceleration at the moment, will there be any difference in sound or performance if I lower the acceleration?
    Here are my current specs,
    Windows XP Pro SP3
    Amd AthlonXP 2600+ @ 2.2ghz
    GB DDR Ram
    ATI x800 xt AIW
    Epox 8RDA3+ Pro
    Running Sata HD and IDE, SATA is the master dri've.
    Some other info,
    The sound card is not shared by any IRQ
    PCI Latency Tool didn't help when I tried to set the latency from 32 to 64
    Bios is updated
    Nforce2 drivers are updated
    Klite codec pack 4.5.3 installed
    kX drivers used instead of Creatives?
    Onboard sound is disabled
    Dxdiag did not find any problems
    Keyboard is connected to PS/2 to USB adapter
    Mouse is connected to USB

    EAudigy 2 Value randomly pops/clicks when the computer is just idling.; I can't figure out why the I hear random popping and clicking when I'm doing absolutely nothing to the computer. Typing this right now doesn't seem to cause any popping. It usually happens when I'm not really doing anything to my computer. This was happening with Creative's drivers and software so I switched to kX drivers, but that didn't help. When I first got my computer (Asus A7N8X-E Deluxe) and got the Audigy 2, I had no problem with Creative's software/drivers at the time, no popping had occur until I installed an SATA HD. PCI latency tool helped at the time. Then I had to go through a reformat and after the reinstallation of Windows XP, the popping started occuring randomly. After my motherboard supposely didn't want to POST anymore, I bought another one which was the Epox. And same problem occured even though I reformat and reinstalled windows.
    Right now, the only thing I could think of that the SATA HD and Sound Blaster cards don't mix well together. But none of these are sharing resources. I did not want to try decrease any hardware acceleration at the moment, will there be any difference in sound or performance if I lower the acceleration?
    Here are my current specs,
    Windows XP Pro SP3
    Amd AthlonXP 2600+ @ 2.2ghz
    GB DDR Ram
    ATI x800 xt AIW
    Epox 8RDA3+ Pro
    Running Sata HD and IDE, SATA is the master dri've.
    Some other info,
    The sound card is not shared by any IRQ
    PCI Latency Tool didn't help when I tried to set the latency from 32 to 64
    Bios is updated
    Nforce2 drivers are updated
    Klite codec pack 4.5.3 installed
    kX drivers used instead of Creatives?
    Onboard sound is disabled
    Dxdiag did not find any problems
    Keyboard is connected to PS/2 to USB adapter
    Mouse is connected to USB

  • When are XA Drivers necessary ?

    Hi all,
    I have a question about the purpose of XA Drivers.
    Time ago we had a bug in a transation processing application
    which doesn't use XA Drivers.
    Because of that bug the application didn't rollback transactions in case of errors.
    Since the ejb that controlled the tx is Container managed tx-Required, I was
    told to investigate that the EJBException was correctly propagated to
    the Container, and that was it.
    So my question is: when are XA Drivers necessary ? only in Bean Managed tx ?
    In CMT since it's the Container that drives the tx, it doesn't matter if I use them or not ?
    Thanks in advance
    Francesco

    Francesco Marchioni wrote:
    Hi all,
    I have a question about the purpose of XA Drivers.
    Time ago we had a bug in a transation processing application
    which doesn't use XA Drivers.
    Because of that bug the application didn't rollback transactions in case of errors.
    Since the ejb that controlled the tx is Container managed tx-Required, I was
    told to investigate that the EJBException was correctly propagated to
    the Container, and that was it.
    So my question is: when are XA Drivers necessary ? only in Bean Managed tx ?
    In CMT since it's the Container that drives the tx, it doesn't matter if I use them or not ?
    Thanks in advance
    FrancescoXA is only needed if your transactions involve more than one DBMS.
    Joe

  • Random Green Screen When Rendering AVCHD In New Imvoies

    Hey everyone I have updated to the new imovie and now when i try and render any movies made in AVCHD it comes up with random flashes or green every few seconds. I have never had this problem before its always been fine until upgrading
    Thanks, Tom

    I am still having the issue randomly Here are some links. The ones from Facebook are "public", hopefully you can see them. I tried going around clicking on videos to get you some links. Some worked and the ones listed below didn't. Thanks
    https://www.facebook.com/photo.php?v=812886258730725
    https://screen.yahoo.com/adrienne-bailon-responds-kim-kardashian-194928794.html
    http://live.wsj.com/video/the-deep-ocean-floor-where-mh370-could-be-hiding-2014-07-31-1211 53013/746BCAF6-B454-4E0C-928A-91154BF5D6CE.html#!746BCAF6-B454-4E0C-928A-91154BF5D6CE
    http://news.yahoo.com/video/meet-aesha-symbol-strength-triumph-233713286.html
    https://www.facebook.com/photo.php?v=649999018402615&set=vb.100001775674235&type=2&theater
    http://www.nick.com/videos/clip/thundermans-120-full-episode.html
    http://news.yahoo.com/weird-delay-pain-brown-recluse-spider-bite-explained-144703443.html

Maybe you are looking for