Skip to main content
November 13, 2011
Answered

Student Question

  • November 13, 2011
  • 3 replies
  • 1894 views

Hello all,

Please forgive my ignorance, from the start.  I'm swimming in deep water, for me.

I have a quiz, set by the professor.  Its a basic OddEven problem.  He's set the parameters of what has to happen.  There are only two boxes and one calculate button.

My text input box has the instance name:   thenumber_txt

My dynamic box has the instance name:    feedback_txt

My button has the name:    compute_btn

When testing the movie I get the complier error 1180 in line 15 of this script:

compute_btn.addEventListener(MouseEvent.CLICK, calculatethenumber);

function calculatethenumber(event:MouseEvent):void

{

    var thenumber:Number;

    var thenumber = number(thenumber_txt.text);  (line 15)

   

    if (thenumber % 2 == 0)

    {

        feedback_txt.text = thenumber + " is even";

    }

    else

    {

        feedback_txt.text = thenumber + " is odd";

    }

    // Start your custom code

    // This example code displays the words "Mouse clicked" in the Output panel.

    trace("Mouse clicked");

    // End your custom code

}

This is as far as I've gotten.  You can tell I'm not a coder. 

Can anyone help me?

I thank you for any help I can get.

This topic has been closed for replies.
Correct answer kglad

case counts in flash.  the Number() function has an upper-case N:

compute_btn.addEventListener(MouseEvent.CLICK, calculatethenumber);

function calculatethenumber(event:MouseEvent):void

{

  // and you don't need to (and should not) declare the same variable more than once

    var thenumber:Number = Number(thenumber_txt.text);  (line 15)

   

    if (thenumber % 2 == 0)

    {

        feedback_txt.text = thenumber + " is even";

    }

    else

    {

        feedback_txt.text = thenumber + " is odd";

    }

    // Start your custom code

    // This example code displays the words "Mouse clicked" in the Output panel.

    trace("Mouse clicked");

    // End your custom code

}

3 replies

November 13, 2011

Thank you both very much!!!!!

At least the button works....now I have to attend to rest of it.

When I test the movie I can see no text input show up, the text type is Input Text,  the font color for that box is black and 28pt  Bold.

If you can spare the time, what am I NOT doing right??

Thanks for the above help.

jdeej

Peter Celuch
Legend
November 13, 2011

Did you use myTextField.embedFonts = true?

Try disabling bold if it helps for now.

November 13, 2011

No I did not.  Where would I put that in the code you see above?

The box works when I enter text but I need it to work when I enter numbers......and then show a conditional when I put in a letter or nothing.

I'll try disabling the Bold.

Thank you for the time given this....apparently I'm lost and have no compass on a cloudy day.

Peter Celuch
Legend
November 13, 2011

I believe you got something like #1180: Call to a possibly undefined method number, which means there's no number() function. Try Number instead.

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
November 13, 2011

case counts in flash.  the Number() function has an upper-case N:

compute_btn.addEventListener(MouseEvent.CLICK, calculatethenumber);

function calculatethenumber(event:MouseEvent):void

{

  // and you don't need to (and should not) declare the same variable more than once

    var thenumber:Number = Number(thenumber_txt.text);  (line 15)

   

    if (thenumber % 2 == 0)

    {

        feedback_txt.text = thenumber + " is even";

    }

    else

    {

        feedback_txt.text = thenumber + " is odd";

    }

    // Start your custom code

    // This example code displays the words "Mouse clicked" in the Output panel.

    trace("Mouse clicked");

    // End your custom code

}