Need help random number, if-then AS3

I found the online AS3 code to generate a random number between 0 and 1.  It looks like this:

function randomNumber1(low:Number=0,_high:Number=1):Number

{

return Math.floor (Math.random () * (1 + high-low)) + low;

}

Then I made two buttons given blue1_btn and green1_btn instance names.  I tried to create a random guess the test button to go to another scene.  Here's the code I used for each with different button

green1_btn.addEventListener (MouseEvent.CLICK, green1);

function green1(event:MouseEvent):void {}

if(randomNumber1 == 1)

{

gotoAndPlay("Win",1);

}

on the other

{

gotoAndPlay("Lose",1);

}

}

The other subsitutes touches the word 'blue' where you see 'green' in the code above.

When I have the test file, I get these errors:

"* Error * Scene 1, layer green btn code ', frame 2, line 3:1176: comparison between a value with static type of function and may be unrelated to int type.

if(randomNumber1 == 1)

"* Error * Scene 1, layer green btn code ', frame 2, line 5:1180: call to a method may be undefined gotoandplay.

gotoAndPlay("Win",1);

"* Error * Scene 1, layer green btn code ', frame 2, line 9:1180: call to a method may be undefined gotoandplay.

gotoAndPlay("Lose",1);

* Error * scene 1, Layer 'code Blue btn', frame 2, line 3:1176: comparison between a value with static type of function and may be unrelated to int type.

if(randomNumber1 == 1)

* Error * scene 1, Layer 'code Blue btn', frame 2, line 5:1180: call to a method may be undefined gotoandplay.

gotoAndPlay("Win",1);

* Error * scene 1, Layer 'code Blue btn', frame 2, line 9:1180: call to a method may be undefined gotoandplay.

gotoAndPlay("Lose",1);

"* Error * Scene 1, layer green btn code ', frame 2, line 1:1120: access of undefined property green1_btn.

green1_btn.addEventListener (MouseEvent.CLICK, green1);

Total ActionScript errors: 7, reported errors: 7

Read errors after seeing corrections below so that you gain a better understanding.  In addition, the arguments of gotoAndPlay are back in your code...

function randomNumber1(low:Number=0,_high:Number=1):Number
{
return Math.floor (Math.random () * (1 + high-low)) + low;
}

green1_btn.addEventListener (MouseEvent.CLICK, green1);

function green1(event:MouseEvent):void {}
If (randomNumber1 () == 1)
{
gotoAndPlay (1, 'victory');
}
on the other
{
gotoAndPlay (1, 'lose');
}
}

Tags: Adobe Animate

Similar Questions

  • Need to random number 1-24, no repeats until all 24 were generated!

    I created an app that reverses a series of 24 flashcards.

    I want my 'go to Random"button to navigate to a number of random frame between 2 and 25, but with no recurrence until he sailed once for each of the images between the two.

    In other words the user does not receive the rehearsals until he got through all the 24 maps - and then repeat the shuffle.

    New flash, thank you.

    I do not distribute solutions when someone has nothing to show for the effort because according to me, it does nothing to help someone to learn... but the level of effort to prepare it was low, then...

    create table

    var nums:Array = new Array();

    Complete the table 1,2,3,4...

    for (var i: uint = 1; i<25;>
    Nums.push (i);
    }

    for the table of brewing

    function shuffle(a:Array) {}
    var p:int;
    var t: *;
    var ivar:int;
    for (ivar =. Length-1; Ivar > = 0; Ivar-) {}
    p = Math.Floor ((Ivar+1) * Math.Random ());
    t = a [ivar];
    a [ivar] = a [p];
    a [p] = t;
    }
    }

    mix table

    Shuffle (NUMS);

    set up controls for the button

    var: County: uint = 0;

    gotoRandomBtn.addEventListener (MouseEvent.CLICK, gotoFrame);

    function gotoFrame(evt:MouseEvent):void {}
    gotoAndStop (nums [count] + 1);
    Count ++;
    if(Count == 25) {}
    Shuffle (NUMS);
    Count = 0;
    }
    }

    This is not tested.  If you have a problem... try to solve it yourself (that's how I learned most of this stuff)

  • Need help with simple if/then script

    I'm trying to replicate a simple if/then statement excel in a PDF form. Have tried several things, but am just not a scripter Java.  The hope that I could get help from the community.

    I have three boxes that contain information on costs. They are labeled LaborCost, MaterialCost & EquipmentCost. Later, in the form, I have two boxes of different output for the sum out of my first three boxes.  If it's a positive number and the other is a negative number.  In Excel forumla language, that's what each of the boxes would read as:

    For the 1st result if it is a positive number: @if (+ LaborCost + MaterialCost + EquipmentCost > 0, + LaborCost + MaterialCost + EquipmentCost, 0)

    For the 2nd result if it is a negative number: @if (+ LaborCost + MaterialCost + EquipmentCost < 0, + LaborCost + MaterialCost + EquipmentCost, 0)

    I think that this should be a simple thing to write, but I'm not familiar with the games of the appropriate language.

    Your colletive help is VERY appreciated.

    Steven

    Try following the calculation script customized:

    // Sum the field values, as numbers
    var sum = +getField("LaborCost").value;
    sum += +getField("MaterialCost").value;
    sum += +getField("EquipmentCost").value;
    
    // Set this field value
    event.value = sum > 0 ? sum : 0;
    

    For others, change the last line:

    Event.Value = sum< 0="" sum="" :="">

  • New on Adobe need help with an if then statement

    Hi, I really like what ADOBE Pro 9 can do with forms and neat and everything is included.

    I'm having a problem trying to understand an if then statement for one of my forms and how to make it executable.

    Here is what I have

    I.          Cigna Medical                                           

                (10)       single                                     $  44.00

                (11)       Employee & Child (ren)              $  82.00          

                (12)       Employee & Spouse                 $  99.00                      

                (13)       Family                                     $125.00                      

                (14)       Decline Coverage                         $0.00          Choice: _        Amount: $_

    An employee will be choice an optiopn 10-14 and but that number of choices. After I am about to fill with this number.

    For instnace, if an employee takes option 11, choice: 11 and amount: $ 44.00

    I put the options in a menu drop-down. The drop down menu is titled CignaMedical and Amount_1 title for amount: $_ and I made a text box.  I put this code: if (this.getField("CignaMedical").value == '10') {}
    Amount_1 = 44.00} tab calculation of properties for the Amount_1 of text box on the custom calculation script tab.

    Any help is greatly appreciate

    Yes, you can use an if-else if construction. Something like that (I got the first part because we reuse it):

    CignaMedical = this.getField("CignaMedical").value;

    If (CignaMedical == '10') {}

    44.00 = Event.Value;

    } Else if (CignaMedical == "11") {}

    Event.Value = 82.00;

    } Else if (CignaMedical == '12') {}

    99.00 = Event.Value;

    }

    etc.

  • need help inventory number of setting in bios on touchsmart 9300

    I'm changing the inventory number in the bios on a 9300.  My company has grown from 9100's which allow you to change, but now it appears greyed out where you cannot change it.  It is important for the way we have these settings in our corporate environment.  Anyone have any ideas?

    Hello:

    This method works on the HP 6200 Pro and HP 8200 Elite desktop PC:

    After entering the Setup by pressing the F10 key, press on Ctrl + A to open additional fields in the security > system menu IDs.

    Enter the serial number of your PC inventory and serial number of chassis number.

    Save the changes then and once when you exit the BIOS.

    Paul

  • I forgot the password of admin, need help. (unique number)

    I have a problem with my computer. I have access to a guest account, but the account admin I need to access an administrator account on my computer, I have a guest account and I have access to cmd, but I cannto run administrative.

    I also use an ibuypower drilling rig. If the spamming f8 does not bring in safe mode. They have their own menu f11 but I don't know how to operate it.

    Can someone help me get into the hidden administrator account or recover the password of my account admin? Thank you.

    Hello

    "What to do if you forget your Windows password"

    http://Windows.Microsoft.com/en-us/Windows7/what-to-do-if-you-forget-your-Windows-password

    "If you forget the administrator password, and you do not have a password reset disk or another administrator account, you will not be able to reset the password. If there is no other user account on the computer, you will not be able to log on Windows and you need to reinstall Windows. »

    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@

    http://support.Microsoft.com/kb/189126/en-us

    Tools third password

    Some third-party companies claim to be able to bypass the password that have been applied to files and features that use Microsoft programs. For legal reasons, we cannot recommend or endorse any of these companies. If you want to help to break or reset a password, you can locate and contact a third party company for this help. You use these third-party products and services at your own risk.

    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@

    Microsoft prohibits any help given in these Forums for you help bypass or "crack" passwords lost or forgotten.

    Here's information from Microsoft, explaining that the policy:

    http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-security/keeping-passwords-secure-Microsoft-policy-on/39f56ef0-5d68-41AD-9daa-6e6019c25d37

    See you soon.

  • Newbie need help to start to learn AS3, help please. ?

    I am very interested to learn action script 3. so please can someone help me

    to start with an excellent material or something you think.

    Thank you.

    Try this site: http://active.tutsplus.com/tag/basix/ it would be a good start for Flash with AS3. The site has also other tutorials for intermediate and advanced levels.

  • Need help to create and then using stored credentials

    I'm looking to automate several scripts to use the

    storage of credentials for script of Alans vCheck

    This post is exactly what I would do:

    # # Save the credentials of the Bank of VI credentials once
    Se connect-VIServer -Server myVC0.domain.com -Credential ()Get-Credential domain\user0() -SaveCredentials

    You could also add the elements of the VI credentials store using the New-VICredentialStoreItem cmdlet.  Using this cmdlet looks like:

    # # Add the credentials to the store
    New-VICredentialStoreItem -Host myVC0.domain.com -user domain\user0 -password supersecretpass

    I'm looking for a way to run my scripts PowerCLI by selecting a VC and calling the - user and - password. I don't know what format to create this? This is what I call the Victoria Cross.

    [CmdletBinding()]

    (param
    [Parameter (Position = 0, mandatory = $true)]
    [System.String]
    $VirtualCenterServer,
    [Parameter (Position = 1)]
    [System.String]
    $ClusterName,
    [Parameter (Position = 2)]
    [System.Boolean]
    $asLocalUser = $true
    )

    $user = C:\vmware\user.txt (not sure what type of file is needed)

    $password = C:\vmware\password.txt (not sure what type of file is needed)

    New-VICredentialStoreItem -Server $VirtualCenterServer -user $user -password $password


    before calling the script/scripts for the - user and - password
    SE connect-VIServer-Server $VirtualCenterServer - user $user-Password $password | Out-Null

    The release of the new VICredentialStoreItem is an XML file.

    You can use the store credenial as follows

    # Save

    New-VICredentialStoreItem-host $VirtualCenterServer - User Admin - password pass - file C:\cred.xml

    # Callback & use

    $cred = get-VICredentialStoreItem-User admin-host $VirtualCenterServer - file C:\cred.xml

    SE connect-VIServer-Server $cred. Home - user $cred. Username-password $cred. Password | Out-Null

  • Need help phone number

    Is there a phone number I can call and ask my question? I can't find a number anywhere on the webcite and I find that so strange. Does anyone know a number I can call?

    Try http://helpx.adobe.com/contact.html

    What is your question?

  • need help serial number

    Re: photoshop cs6 teachers edition

    before installing this software, buyer must obtain a serial number by submitting proof of eligibility to Adobe. Product may not be used without such proof. My copy was bought in a shop. I was told do not to open the installation box until I get the serial number.

    Question: Anyone know where I can find info to start the process?

    Adobe - student edition order fulfillment

    Mylenium

  • How to generate a single random number in a MySQL database

    I create a volunteer and also a separate request form from the seller for an air show. The volunteer and seller info is stored in separate tables in MySQL db, a line by volunteer or the seller. There will be about 100 volunteers and 50 sellers. When the request should immediately be printed by the applicant signed and mailed in. This year we had problems with some people who do not immediately print asked, so I would still give them the possibility to print immediately, but also to send them an email with a link to their specific line in the MySQL database. I have an AutoIncrement primary key for each table field, but I think to send this key to the applicant in an email would be too easy for them to guess a different id and access the information of others.

    I think I should add a column for each table containing a unique random number and then I would send this key in the e-mail to the applicant. So, can anyone suggest a simple way to do this or suggest a better way to give the applicant a way to access their own request and nobody elses not after submitting their form?

    Thank you all.

    Tony Babb

    In your code, you should:

     VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, $s)",
    

    Change the $s to %s and that should solve the problem for you.

    Let me know.  Thank you!

    Chad

  • Need help with a JavaScript to generate random number

    Hello

    First things first. I don't know the JavaScript J.

    When I thought about a ready to use solution to generate a random number in Captivate, I found this on a forum of LinkedIn.

    (1) add a user to your project variable, called "NombrAl". Its value can be zero.

    (2) add a text caption with ' $$randomNumber$ $"inside, to check if your script works.

    (3) add a button to the slide. Give him one on success Action to run JavaScript. Clear the check box 'continue playing the Project '.

    (4) add the following text in the button Script_Window:

    var objCP = document. Captivate;

    var rand = 1 + Math.floor (Math.random () * 10);

    onButtonClick() {} function

    objCP.cpEISetValue ('NombrAl', rand);

    }

    onButtonClick();

    However, it is (as the poster in the forum warned) for 7 Captivate does not. Can someone please help?

    I am open to all other methods to achieve the same result.

    Thanks in advance,

    Anthony

    Hi Anthony,.

    During the test, make sure that you are testing from a web server where the web address starts with http or https.  When you set the captivate variable "NombrAl" try this instead:

    objCP.cpEISetValue ('m_VarHandle.randomNumber', rand);

    This will work for the SWF output.  If you want to work for the release of HTML5 and SWF, try this code:

    window.onButtonClick = function(){
              var rand = generateRandomNumber(1, 10);
              setCpVariable('randomNumber', rand);
    
    };
    
    window.generateRandomNumber = function(min, max){
              var randomNum = 0;
    
              if(!isNaN(parseFloat(min)) && !isNaN(parseFloat(max))){
                        min = Number(min);
                        max = Number(max);
                  randomNum = Math.floor(Math.random() * (max - min + 1)) + min;
              }
    
              return randomNum;
    };
    
    window.setCpVariable = function (cpUserVariableName, variableValue) {
              /* Check for HTML5 vs. SWF output */
              if (typeof window.cp === 'undefined') {
                        /* We have SWF output, so Get the Captivate Object */
                        var objCp = document.getElementById('Captivate');
    
                        if (objCp && objCp.cpEISetValue) {
                                  /* Set the Captivate User variable with the JavaScript variable, variableValue */
                                  objCp.cpEISetValue('m_VarHandle.' + cpUserVariableName, variableValue);
                        }
              } else {
                        /* We have HTML5 output */
                        /*If variable does not exist off of the window object, then use the variables manager*/
                        if (typeof window[cpUserVariableName] === 'undefined') {
                                  if (cp.vm && cp.vm.setVariableValue) {
                                            cp.vm.setVariableValue(cpUserVariableName, variableValue);
                                  }
                        } else {
                                  window[cpUserVariableName] = variableValue;
                        }
              }
    };
    
    window.onButtonClick();
    

    Don't forget to test this situation from a web server either local security prevents the javascript code for execution.

    Best,

    Jim Leichliter

  • [Error number: 0x8024400A] Need help with this error... I reinstalled XP SP1 and I can't get an auto update that's simple to install, just get this error every time

    [Error number: 0x8024400A] Need help with this error... I reinstalled XP SP1 and I can't get an automatic update that's simple to install, just get this error at each time HHHHEEEELLLPPPPP! Thank you

    I had the same problem.  But finally found a solution.  If your listing is similar to mine, then keep.  XP Media Center Edition 2005 (sp2).  AMD Athlon 64 x 2 Dual-Core, HP a1630n desktop computer.

    Go to the HP website, search for sp37394-XP sp3 Upgrade utility Microsoft for systems equipped with AMD processors.

    I had the same 0 x 80240036, 0x8024400a error, but realize my problem was really get manually downloaded sp3 and installed without continue loop crashing and not error messages.

  • Need help to reactivate Lightroom 5 with my old serial number and the number TAN.  I got a license for Lightroom 5 when I bought my Leica delux 4 in 2012.

    I got a license for Lightroom 5 when I bought my Leica delux 4 in 2012. It worked great, but after that I put an old hard drive on my PC (for 30 minutes - then I removed again) to get some information of this former, Lightroom now license application or try it for 30 days.

    I have not installed Lightroom on a new hard drive. He is always on the same hard disk. How can I now have my Lightroom to run again using my serial number and TAN? Need help to reactivate my old serial number and the number TAN.

    I use win 7.

    Duplicate thread: need help to reactivate Lightroom 5 with my old serial number and the number TAN.  I got a license for Lightroom 5 when I bought my Leica delux 4 in 2012.

  • Hi, I'm changing payment five days ago mi information (I need to change the credit card number), but something happen and appears an error with this announcement page: "error number: PMT_000008" then... What should I do?

    Hi, I'm changing payment five days ago mi information (I need to change the credit card number), but something happen and appears an error with this announcement page: "error number: PMT_000008" then... What should I do?

    Since this is an open forum, not Adobe support... you must contact Adobe personnel to help

    Chat/phone: Mon - Fri 05:00-19:00 (US Pacific Time)<=== note="" days="" and="">

    Don't forget to stay signed with your Adobe ID before accessing the link below

    Creative cloud support (all creative cloud customer service problems)

    http://helpx.Adobe.com/x-productkb/global/service-CCM.html

Maybe you are looking for

  • How to superimpose photos in iMovie?

    I don't know how to superimpose an image on a video clip on the iMovie iPad version. I can only overlay video clips. all the answers?

  • How to escalate a case in the USA?

    I have dealt with MS India for weeks on a windows update problem. They're constantly missing call time, I asked that a supervisor call me - they do not have. The system is much worse today than when I called through their work - I have never the same

  • Crash random outlook

    Hi all. I have a computer with windows 7 SP1 64-bit and we faced problems with Outlook 2003Several times the crash outlook when I create or send an e-mail.In my event log, I see all the time the same mistakes.Event id 1023 .NET Runtime and event id 1

  • Continuous Alert / Notification until the confirmation

    I have been working on this for awhile and tried several methods.  I have an application where the data is pushed to the device.  If it's a specific set of data, then a notification/alert must be activiate until the user acknowledges the message. I d

  • sites Web WYSIWYG

    A site built with Contribute (wysiwyg) can be uploaded to Muse?