Random generation of numbers and their use in mathematics

I m doing a project and had an idea to do a math game thing where the numbers are generated randomly in both slots. For example, it is between 1 and 100 and the other the same and then add them up. The player will have to add them together and then type them in the reply box and if it's correct or not. I need help with the coding, as I'm new to CS5.

I worked with a more ancient and outdated Flash version a little more than a year. So I know a little things General and some of the things that must be accomplished. However, ActionScript is fairly new, and I tried to use mathematics. Random because it seems that everyone uses in their tutorials. Yet, I couldn't make it work when playing with it. After you have created the random number, as I said before, I would like to be able to add/subtract/multiply/divide them to another number for an answer, but not to display the answer until a button is hit with the response users. Any help would be greatly appreciated.

Thank you.

If any other information is necessary, I can give that info.

Assuming that your implementation of the stage via the Flash IDE, you can do 4 text boxes and give them instance names leftNumber, answerNumber and mathSymbol, rightNumber. Also create a button with an instance name someButton.

Make sure that the first 3 fields (leftNumber, mathSymbol, rightNumber are dynamic and the answerNumber field is entered).

Set your document class hand (file-> setting Actionscript-> Document class-> tpye in 'Hand'

Now create a new as3 at the same level as your FLA and name it Main.as

Here is an example of code that I did very briefly to your main class.

Obviously, this has been done short hand and needs some changes, but it should help you get started (sorry for the [lack] of formatting).

package

{

import flash.display.MovieClip;

import flash.events.MouseEvent;

SerializableAttribute public class Main extends MovieClip

{

private const HIGHEST_NUMBER:Number = 100;

private var randomLeft:Number;

private var randomRight:Number;

private var randomOperator:String;

private var correctAnswer:Number;

public void Main (): void {}

create random numbers

randomLeft = Math.floor (Math.random () * HIGHEST_NUMBER) + 1;

randomRight = Math.floor (Math.random () * HIGHEST_NUMBER) + 1;

var operatorSwitch:Number = Math.floor (Math.random () * 3) + 1;

If (operatorSwitch == 1) {randomOperator = '+';}          }

Else if (operatorSwitch == 2) {randomOperator = "-";}          }

else {randomOperator = 'x';          }

correctAnswer = solveProblem();

setupDisplay();

This ['someButton'] .addEventListener (MouseEvent.CLICK, checkAnswer, false, 0, true);

}

private void solveProblem (): number {}

If (randomOperator == '+') {return randomLeft + randomRight;}          }

Else if (randomOperator == '-') {return randomLeft - randomRight;}          }

else {return randomLeft * randomRight;}          }

}

private function setupDisplay (): void {}

This ["leftNumber"] .text = String (randomLeft);

This ["rightNumber"] .text = String (randomRight);

This ["mathSymbol"] .text = String (randomOperator);

This ["answerNumber"] .text = '? ';

}

private void checkAnswer(evt:MouseEvent):void {}

If (Number (this ["answerNumber"] .text) == correctAnswer) {}

trace ("YOU SMART if");

} else {}

trace ("TRY AGAIN");

}

}

}

}

Tags: Adobe Animate

Similar Questions

  • Another question on local Variables and their use.

    I have read many many posts on forums how we avoid the use of locals at all costs because they go against the stream of LV paradigm however I tried to find a way to replace them in my programs and do not have.

    Basic explanation:

    I use a state machine to browse specific validation test steps and test of electronic equipment of base. (Panels, timers, relays moduals fuses) Many of these facilities contain LED indicator. In the tests, I took photos of the products and then used the Boolean flags to replicate the LED on the PC so that the test operators can check to make sure the equpiment LED turns on as needed. My problem is that many products contain 20 + LED and have no order to how they are turned on. Because of this that I eventually do a boolean for each LED indicator, put all the indicators in a structure of disabled, then using local Variables at each step to display on the FP LED should now be on. It's often a lot of locals throughout the program.

    I tried to make a very basic sample of VI to try to show what is a normal procedure. How can I reduce the amount of local Variables without increasing the complexity of my VI?

    If the LED change of State within the meaning of the criterion - within the case statement - you need a parallel loop.

    I did a heap of your LED and does an architecture of producer/consumer of your case, 'Test 2' attached.

    Edit: In my table, on the bottom line, the text should read "your 6 LEDS are now a Cluster" rather than "your 6 are LED not a Cluster."

  • Types of Apple ID and their uses as pseudonyms AIM

    Hello

    Apple used to have two methods of creating an Apple ID.

    One was to register and email outside and connect with that.

    The other was to create an ID @mac.com

    This could be a trial account in the beginning or paid to the account.  Paid accounts gave access to additional features.

    Trial accounts would end automatically but the ID would continue to work for iChat under a valid AIM screen name (you added it as if it were OBJECTIVE and used the Apple password.

    Unused accounts would also retain their ability to works like pseudonyms AIM

    The MobileMe Service, which was also paid, but also came with a trial period came later.

    The trial had to be cancelled before the trial ended, or you have been charged and no longer work as pseudonyms AIM

    Expired account also is more worked if it is not paid for.

    In the variation between the services there two you can choose to link all @mac.com account and @me.com ID.

    For the mail, they worked as an ID but in iChat and Messages later, they worked as separated as pseudonyms ID valid even if the passwords are the same.

    More recently, we have iCloud who has less services that are related, but are free.

    More Apple ID can be linked to iCloud and this includes those indicated above and any other from other e-mails apart from the setting in place of Apple.

    This may mean that you have @mac.com, @me.com (related to iCloud f) and an ID of @icloud related to Apple who worked as separate from the screen in the iChat application names.

    You may also have an external e-mail that you access iCloud who may have given you a @me.com address so early and a @icloud.com later one more which are related, but, again, are distinct pseudonyms valid for the objective.

    You will notice the italic "worked" in clause 2 above.

    On July 1, 2014 Apple and AIM changed this OS X: ID me.com or mac.com with AIM in iChat requires OS X v10.7.2 or later - Apple Support

    OS X 10.7.2 brings a change to iChat 6.

    At this point the Messages saved in both objective and Apple to confirm it was you connect.

    iChat 1 so 5 and the beginning iChat 6.0 does not have this connection double check capacity year old ID does not work.

    In truth, neither do @iCloud.com those but older apps do not list add the options of "@icloud.com ' screen names.

    These names all work on the later versions of Messages and the latest version of iChat 6 as described above.

    20:50 Monday. April 4, 2016

     iMac 2.5 Ghz i5 2011 (El Capitan)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro (Snow Leopard 10.6.8) 2 GB
     Mac OS X (10.6.8).
     a few iPhones and an iPad

    Hello

    If Yahoo or Google are also your call ID?

    It seems that these may be accounts in Messages as well.

    iChat Alias

  • Recording of data and their use

    I have to build a flash game, where a function that collects the data of the user.

    later, separately, I have to build a game that uses the data collected before.

    I think that to do this in the following way: catch the first step of the user data and store them in xml. Then issue the data from the xml file to use the second game.

    Issues related to the:

    1 - is the right way? Logic?

    2. do you know a better way?

    3. I have a great experience with the ready help of xml files, but never created a Flash xml file. What am I supposed to know for her? What classes etc.?

    4. I found a class that can help him, but he opens a conversation box, that the user can choose the location of the file and the name (FileReference). Can I avoid this? I mean: I want to choose a place name and case number, without the user can control. Is this possible?

    5. given that, I have to download the file (xml) on the server, will have a size limit?

    Thank you!

    If the swf file is to check the responses, I'm not sure what you want to save to the server.  the value of an outcome variable?

    in any case, you must use something like:

    AS3

    var urlLoader:URLLoader = new URLLoader();

    var urlVariables:URLVariables = new URLVariables();

    var urlRequest:URLRequest = new URLRequest("php/savefile.php");  //<-use your="">

    urlVariables.scoreVar = result;  //<-saving a="">

    urlVariables.filenameVar = "score_" + username + ".txt"; //<- saving="" the="" score="" to="" a="" text="" file="" using="" a="" file="" name="" that's="" related="" to="" the="" user's="" name. ="" if="" there="" might="" be="" a="" name="" collision,="" append="" a="" random="" variable="" to="" ensure="" no="">

    urlRequest.data = urlVariables;

    urlLoader.load (urlRequest);

    /////////////////////////

    PHP

    
    
  • Why a strange alphabet does not appear when I type in an address box. Integration is slow and hesitant and numbers and letters are often repeated on their own?

    I use the new Sierra, but the problem predates this.

    Whenever I am typing a command or an address, a strange alphabet appears with blue letters and numbers below. The stalls, insertion and numbers and letters and then repeat on their own. I can't get out.

    This problem comes and goes, no real reason for when it happens.

    It happens when I type in the Web addresses, etc., and when I type the commands of the operating system.

    Can you give more information on mac hardware.

    You can download and run the latest version 3.0.5 of Etrecheck (etrecheck.com)

    and post it here please.

  • question to insert random generation between 1 to 5 numbers

    Hello all;

    I have the sample data
    create table zone2
    ( ID varchar2(500)
    );
    
    insert into zone2
      (ID)
    values
      ('A');
    
    insert into zone2
      (ID)
    values
      ('B');
    
    insert into zone2
      (ID)
    values
      ('C');
    insert into zone2
      (ID)
    values
      ('D');
    
    insert into zone2
      (ID)
    values
      ('E');
    
    insert into zone2
      (ID)
    values
      ('F');
    
    insert into zone2
      (ID)
    values
      ('G');
    I use the insert select statement to transfer things in the table below
    create table zone1
    (
      ID varchar2(400),
      scanno number(30)
    
    );
    See my insert select below
    insert into zone1 (ID, scanno)
    select zone2.ID from zone2
    My question is so fundamentally during my select insert, I want to be able to generate random numbers from 1 to 5, it can be in order descending or not and these random numbers will be used for field scanno in zone1, so basically that's what I want to see recorded in the table of the zone1
    ID  scanno
    A        1
    B         2
    C        3
    D        4
    E        5
    F        1
    G       2

    If you really want random numbers

    insert into zone1 (ID, scanno)
      select zone2.ID, floor( dbms_random.value(0,6) )
        from zone2
    

    Justin

  • Generation of numbers used

    Hi guru,.

    I created the Group of business with the type of generation number used as automatic. After that I changed it to manual.

    Now, I'm not able to create employees, employee number field is grayed out and when I record it is poping up error message to enter the number of the employee.

    Please let me know how to solve this problem.

    Thanks in advance.

    Stalin G

    Hi Stalin,

    I use 12.1.1. I just tried your scenario. It works great both ways. I could turn the generation of numbers from automatic to manual in the bus. Group of information and reverse in running "change the number of people in auto." After each change, I created an employee and it works without any problem.

    You must run "person of change of automatic numbering. Never run "change person number genaration in overall sequencing. This is used for global deployment and an irreversible process.

    If this does not help, let me know. I'll suggest a few options of profile.

    Hope it works.

    Kind regards

    Jeeves

  • Why the Pages and Numbers do not use the default printer?

    Recently, I added a second printer to my home network and selected as the default printer. But when I try to print, the correct printer is selected in the dialog box print only part of the time and apparently depends on which application to print from. I believe that Safari, Mail, Contacts and calendar properly use the default printer, then the Pages and Numbers and instead do not the old printer unless I have change the selection in the dialog box impression every time I print.

    How can I get Pages and Numbers to correctly use the right default printer?

    The problem that is happening on my machine (OS X El Capitan 10.11.2, 5.6.1 Pages and numbers 3.6.1) and my wife (running Maverick 10.7.5, Pages ' 08 3.0.3 and Numbers ' 08 1.0.3) and has persisted through a reboot. The old printer is a HP OfficeJet Pro 8600, accessible via WiFi. The new printer is a Brother MFC-7340 connected by USB to a Time Capsule that is accessible via WiFi.

    In the print... dialog you select

    View the Presets...

    in the menu presets. In the sheet drops down, uncheck the box marked

    Reset the Menu Presets for "Default settings" after printing

    Click OK. Then select

    Last settings used

    or a custom preset that you created in the menu.

  • Digital and analog generation and acquisition using USB-6251

    Hi all

    I have to actually synchronize a 6251, USB and USB 6366 Board. I have a vi, which is good that now I am able to use the 6366 as the master and as slave 6251, attached tie. The master generates a digital trigger for (generation synchronization) pulse and the acquisition of the signals on both cards, analog signal ramp and acquires signals. The slave acquires only a series of signals after outbreak.

    I want to have the 6251 as master and as slave 6366. The vi attached the other way around as I mentioned above. When I try to use the 6251 as the master, I get an error asking me to specify the clock source (I did the material and some changes in the program as well, as export properly 6251 at 6366 clock).

    Thank you

    SANJU

    Thanks for your reply jonathon,

    But in your code below, I coudnt get the Outpput internal PCI-6251/ctrl0...

    but I hardwaired the o/p (PFI 12) meter... .and generated a signal meter on this port, I used that as the clock...

    Thank you

    SANJU

  • Why the new upgraded yahoo email system doesn't let me use numbers and chips more?

    Why the new upgraded yahoo email system doesn't let me use numbers and chips more?

    Hello

    You will need to contact Yahoo support for a better response with the new Yahoo Mail.

    You can also post your queries to http://answers.yahoo.com/

  • How to get the friend list and their IDS in the integration of Facebook using Facebook SDK

    can any body send me the code
    How to get the friend list and their IDS in the integration of Facebook using Facebook SDK
    I did after connection and wall

    Welcome on the support forums.

    Please check the strawberry sample that ships with the SDK

  • Use of the BAT file - how do you completely remove 150 phones and their associated DNs?

    How do you remove completely 150 phones and their associated DNs? All phones are in the same pool of device. I prefer the way bat.

    The CUCM version: 8.6.2

    Type of phones: 7962 phones - associated with the same device pool.

    Other questions: is there a way to remove all phones and their associated DNs with elegance when all phones are associated with the same mass of device? I rather not work with extensions and MAC addresses.

    Thank you

    Hug Lupas

    Hello hug,

    Using the BAT, it will take 2 - passes. 1 for unassigned phones and 1 for "DN". This is well illustrated in the attached doc;

    http://www.Cisco.com/c/en/us/TD/docs/voice_ip_comm/CUCM/bat/8_0_1/bat-80...

    Of course for the DN you could remove through the road map report > unassigned DN > select all > delete

    See you soon!

    SoC

  • I tried the license of my trial version of photoshop elements, but the download is for windows and I use a mac.  Secondly, I get an error message saying that the serial numbers provided by Adobe in the received email are not correct.

    I tried the license of my trial version of photoshop elements, but the download is for windows and I use a mac.  Secondly, I get an error message saying that the serial numbers provided by Adobe in the received email are not correct.

    Regarding the download, the correct trial version going, you should be able to manage on the link below.  If you have made a purchase and bought a Windows license so it is not valid for a Mac installation.  You will need to contact the Support from Adobe when they go bacvk vacation to see about getting the correct license.

    You can download the demo version of the software through the page linked below and then use your current serial number to activate it.

    Don't forget to follow the steps described in the Note: very important Instructions in the section on the pages of this site download and have cookies turned on in your browser, otherwise the download will not work correctly.

    Photoshop/Premiere Elements 14: http://prodesigntools.com/photoshop-elements-14-direct-download-links-premiere.html

    To the link below, click on the still need help? option in the blue box below and choose the option to chat or by phone...
    Make sure that you are logged on the Adobe site, having cookies enabled, clearing your cookie cache.  If it fails to connect, try to use another browser.

    Get help from cat with orders, refunds and exchanges (non - CC)
    http://helpx.Adobe.com/x-productkb/global/service-b.html ( http://adobe.ly/1d3k3a5 )

  • Random numbers and generate funds

    Hello.

    I would like to create a very simple equation random addition.

    I have: 3 boxes of dynamic text (r1_txt, r2_txt, a1_txt)

    I want the first two random numbers and 'a1_txt' to display the sum of the first two random numbers.

    Everything is perfect to the point of adding the two numbers and drop the answer in a1_text. What should I do for my last line of code?

    Thanks for your help!

    random numbers
    1.
    function randomNumbers (min:Number, max: Number) {}
    var Results:Number = Math.floor (Math.random () * max) + min;
    return results;
    }

    2.
    new_mc.addEventListener (MouseEvent.CLICK, showRandomnumber);

    3.
    function showRandomnumber(event:MouseEvent):void {}
    r1_txt. Text = randomNumbers (1,100)
    r2_txt. Text = randomNumbers (1,100)
    a1_txt. Text = Number (r1_txt.text) + Number (r2_txt.text);
    }

    Your showRandomnumber() function has a few problems.  TextFields working with channels, so whatever it is assigned to a textfield must be a string value.  You should actually get errors for the first two lines.

    function showRandomnumber(event:MouseEvent):void {}
    r1_txt. Text = String (randomNumbers (1,100));
    r2_txt. Text = String (randomNumbers (1,100));
    a1_txt. Text = String (Number (r1_txt.text) + Number (r2_txt.text));
    }

    If you change which is not fix things, then look to your textfields to the problem

  • Problem creating java objects in DB tables with numbers in their name.

    I use JDeveloper 11.1.1.0.2 to create toplink pojo to database Oracle 11 g. Many of the tables have numbers in their names. When I create java objects to tables, for some reason any all numbers are abandoned on the names. If a table with the name T1_TRANS creates a java object named TTrans instead of T1Trans. The numbers are also abandoned as well domain names.

    I have previously built pojo for this database with JDeveloper10.1.2.X and have never experienced this problem. All the class and property names can be changed by hand, of course, but with the number of tables in this database that would be very time consuming.

    Is there a setting somewhere that I'm missing? Any help would be greatly appreciated. Thank you.

    Hello

    This is a bug that the numeric values in table names must be included in the generated class names. We have addressed this issue and the fix should be available in the next major release of JDev. In step 5 of Tables Wizard Java objects, you can rename the default class for each table names before the generation. This approach is little if all goes well-less bulky that rename classes after generation. However, there is no best solution for workaround. Let me know if I can provide you with additional information.

    Thank you, John

Maybe you are looking for

  • iTunes iOS 7.1.2 connection problem

    I have iPhone 4 (model: A1332) with iOS installed 7.1.2.  When I try to enter in iTunes app it gives following message and doesn't show anything on the content. What is the problem? I can connect to iTunes with my Apple ID on my iPad 2 with iOS lates

  • How to change DVD region on Satellite P500 settings?

    Hello everyone, thanks to Pau Pau and Xarxas for their information in this new day, but I have to be more desperate than I thought. I can't seem to locate the Device Manager icon that will allow me to move to the region 4, I'm not on my laptop now, b

  • Re: Satellite L550-17R: black screen with 1024 x 768 @ 50 Hz

    Hello We recently bought 2 portable Satellite Pro L550-17R for use as machines to show that the production of projectors at conferences and live events. Both machines are identical in spec, and the intention is to run them both at a resolution of 102

  • Pav p6243w: change of RAM

    Hi im new to the forum. Names of Mike. my computer is 2009, but tech support said that I did not need to buy a new one for a faster speed. He slowed down, so first I bought an OEM Samsung DDR2 2 GB to replace the 1 GB installed on location DIMM # 1.

  • Error Oxc0000135

    After you download an update from Windows, I was unable to get Macafee works properly and then I used the restore application to restore my laptop to a previous restore point, I received an error message Logon.scr - Application error the application