Flash Advisor logo
:: Desktop Shortcut
:: Flash Help
Advice from Experts

+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
  1. #1

    Default if statment help URGENTLY

    okay im making a quiz like thingy and basically...
    these are the instance names
    markit_btn1 this is the button that the user clicks to get the results of their answers
    proton number 1 this the input text where the user types in the answer
    pans1 this is the dynamic text that i made where it should say correct or wrong
    can someone please tell me how to make the code im soo confsed this is what i got so far

    Code:
    markit_btn1.onPress = function()
    {
         if (proton number 1== "3")
         {
              pans1 = "Correct";
         }
         else
         {
                pans1 = "Wrong";
         }
    please help me
    Last edited by Vlykarye; 12-22-2011 at 08:07 PM.

  2. # ADS
    Join Date
    Always
    Posts
    Many
     
  3. #2
    Join Date
    Jun 2009
    Location
    Houston, Tx
    Posts
    485

    Default

    Hey. I'm reading your post, so give me a minute.

  4. #3
    Join Date
    Jun 2009
    Location
    Houston, Tx
    Posts
    485

    Default

    Ok. First off, we can see that your code is missing an } at the very end.
    Second, if you're trying to become a programmer, then for an important starter tip, do not abbreviate your variable names. Instead of 'markit_btn1' you should name it 'markItButton1' or pick an even better name such as 'getResultsButton'.
    Third, 'proton number 1' is an invalid variable name. You cannot put spaces in variable names.
    As for the 'pans1' variable, I need more information. You need to tell me:
    • State which version of Adobe Flash Pro is being used, if necessary.
    • State which version of ActionScript is being used, if necessary.
    Then, you need to tell me more general information about what you are trying to accomplish and how you want it to work. Do you have text boxes on the screen? Do you have movieclips? Just give me more information in general.
    Consider changing 'pans1' to 'protonAnswer1' if that is what you were going for.

  5. #4

    Smile

    im using flash 8
    and actionscript 2.0
    basically
    when the user types in their answer i want it to say correct or wrong when the button is clicked .
    i have a text box that iv changed to input text in the properties this is where i want the user to type in the answer i named the instance namefor this proton number 1 (which ill change to what you said befor)
    i have a dynamic textbox next to it where i want it to say correct orwrong depending on the answer of the user- the instanse name for this is pans1 (which ill also change later)
    and i have the button where, when the user clicks it i want all of the above stuff to happen so whent he user clicks i want it to say wheather the answer they gave its right or wrong in the dynamic text box
    HELP ME
    i havent made any movie clips
    this is the new code i made

    results1.onPress = function()
    {
    if (protonnumber1 == "3")
    {
    protonanswer1 = "Correct";
    }
    else
    {
    protonanswer1 = "Wrong";
    }
    }

    i get an error though
    **Error** Scene=The structure of an atom, layer=markit buttons, frame=2:Line 1: Statement must appear within on handler
    results1.onPress = function()

    Total ActionScript Errors: 1 Reported Errors: 1
    Last edited by purple123; 12-22-2011 at 09:21 PM.

  6. #5
    Join Date
    Jun 2009
    Location
    Houston, Tx
    Posts
    485

    Default

    K. First a few things.
    You don't need to worry about making the variable names pretty if you're not planning on becoming a programmer. That was just in case.
    When asking for help on forums, try not to type things like URGENTLY, or HELP ME, or NEED HELP FAST. It is obvious that you need help, and that you probably want it sooner than later. Just stay away from begging or ALL CAPSing things like that.

    You get that error because you're typing code into a movieclip. If you want code in a movieclip, you need to follow the rules of coding, which you can read from the Help Contents that came with Flash 8. Or, you can go to Adobe.com and read about ActionScript 2.0 MovieClips in their help docs.

    As for what you want the program to do, you're code looks logically correct. However, you cannot use the 'instance name' of the text boxes like that. Go to the properties of your text boxes and put the name into the box that says "variable" in order to use it like a variable. Otherwise, you must treat the 'instance name' as a TextField class, which is what it is. The text inside the text box is a property called 'text'.

    protonanswer1.text = "Correct";
    This is logically and syntactically correct if you are using the 'instance name' for your text boxes.

  7. #6

    Default

    oh okay ill try it now thanx

  8. #7

    Default

    it still didnt work
    can i just make sure that im doing it right
    from what you said instead of putting the names in the instance name place i put it in the var box
    and i added.text to the end of them
    but its still not working forsome reason
    no errors are showing up
    do i convert the dynamic boxes to movie clips
    this is what the code looks like now
    results1.onPress = function()
    {
    if (protonnumber1.text == "3")
    {
    protonanswer1.text = "Correct";
    }
    else
    {
    protonanswer1.text = "Wrong";
    }
    }

  9. #8
    Join Date
    Jun 2009
    Location
    Houston, Tx
    Posts
    485

    Default

    If you put them in the variable box, treat them like a variable.

    If you put them in the instance name box, treat them like a TextField class. You must put .text for this path.

    Tell me what happens.

  10. #9

    Default

    ..... it kinda worked lol ugh problems thanks for your help so far

    when i typed in 3 in the flash game thing i making it said wrong instead of right
    any ideas

  11. #10
    Join Date
    Jun 2009
    Location
    Houston, Tx
    Posts
    485

    Default

    Haha. Alright, at this point, I don't know how much more I can help you vocally. However, if you send me the file over email or something, then I can take a look and see what might be causing the problem. Let me know if you would like to and I'll give you my email address through a private message.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Sponsors
Create Speaking Characters for your website and Flash movies. 15 Day Free Trial