How to create a loop for below code?

Help with counting code in Flash?

  • Help with code for counting This question is Not Answered.(Mark as assumed answered) Hi I am new at coding and such, in school they give us project builders before the assignments, they are generally much harder but are for practice and trial and error. This one I am completely lost on. They supply a code for a counting came, a cookie charge that is spilled when pressed and the user needs to count the spilled cookies and input the number.The wrong number will not work so there is a loop feature in this i think. here is the code supplied that needs things added. stop(); var numberOfCookies:Number = 0; startBtn.addEventListener(MouseEvent.C… function getCookies(Event:MouseEvent) { numberOfCookies = (Math.floor(Math.random()*(10))+1); var n:Number = 0; } Now here are the long instructions on what needs to be done, Complete the getCookies function by typing code for the following before the closing right brace: Add a line below the last line of code and before the closing right brace to create a while loop that loops while n is less than numberOfCookies. Define the while loop as follows and place the code inside left and right braces: Type a line that creates a variable named cookieInstance that has a cookieMC data type. Create a new instance of the cookieMC. Note: cookieMC is the movie clip that contains an image of the cookie. Add another line of code that uses the addChild method to add cookieInstance to the display list and positions it in a random location. Hint: Your text features an illustration that depicts the addChild line format. The x values should be 200 and 20, and the y values should be 150 and 220. This will ensure the cookies will overlap with the cookie jar! Add another line of code that increments n by 1. Verify both the while look block of code and the getCookies function block of code end with right braces (}). After the closing right brace for the getCookies functions, type an event listener that calls a function when the goBtn object is clicked. Name the function checkNumberTyped. Define the function as an if-else statement. If the number entered by the user into the input box (checkBox.text) is equal to the number of cookies (numberOfCookies) generated by the random function, then have the playhead go to and play frame 2; or else have the playhead go to and play frame 3. Check the syntax and auto format the code. Click frame 2 on the Timeline. Click the dynamic text box just below the heading on the Stage and give it an instance name of right. Click frame 2 on the actions layer. Then display the Actions panel. Note: The code in Line 2 adds an event listener that "listens" for an ENTER_FRAME event and names a function (correct). The enter frame event causes the function named correct to be executed when the playhead moves to frame 2. Type the line of code between the left and right braces ({}) that takes the value in the numberOfCookies variable and changes it to a string data type and then assigns it to the dynamic text box named right. Hint: the format to change a numeric var to a string is: Textboxname.text=String(var); Check the syntax and auto format the code. Click frame 3 on the Timeline and click the dynamic text box on the Stage and give it an instance name of wrong. Click frame 2 on the actions layer and copy the code for the event listener and the function called correct. Then click frame 3 on the actions layer and paste the code on a new line following stop();. Edit the code pasted into frame 3 on the actions layer so the function name is incorrect and the text box name is wrong. Check the syntax and auto format the code. Test the movie several times by entering both correct and incorrect numbers for the number of cookies displayed. Now this is my first Flash class, and I have been in it for 7 weeks, I feel this is a lot to know already, but if someone could tell me what I need to add and why i would have a great understanding before the project comes up that I will need this practice run for.

  • Answer:

    7 IS THE ANSWER!!!!!!!!!!!!!!!!!

Dt Rockweiler at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.