Skip to main content
Participant
April 26, 2012
Question

problem with action script 3 make input text box and button....

  • April 26, 2012
  • 1 reply
  • 1511 views

Hi every one I am trying to make a family book using "Air for Android" with a simple search engin in the book

air for android only work with AS3,

the search function is to type a person's name and hit submit then go to a specific frame.

have a problem making below code to work in AS3 and hopefully one of you guys can lead me in the right direction to fix the issue.

Currently, I have an input text box and a button. When you type specific words into the input box and then hit the button it sends you to a specific frame.

(it work find in AS2 but not in AS3,)

Here is my current code that is placed on the main timeline, first frame:

stop();

onEnterFrame = function () {

    submit.onRelease = function() {

        switch (yourname.text) {

        case "name1" :

            gotoAndStop(2);

            break;

        case "name2" :

            gotoAndStop(3);

            break;

        }

    };

};

My button that checks if the phrase is correct is called "submit" and my input box has an instance of "yourname".

My phrases that will be accepted in the input box are "name1" and "name2" which bring me to two different frames.

Basically, I'm having a problem with making this to work with AS3.

This topic has been closed for replies.

1 reply

_spoboyle
Inspiring
April 26, 2012

it isn't an exact conversion (why would you create a function every frame?) from your code but it does the same thing

stop();

submit.addEventListener(MouseEvent.CLICK, onSubmit);

private function onSubmit(e:MouseEvent):void

                    {

                              switch (yourname.text)

                              {

                                        case "name1":

                                                  gotoAndStop(2);

                                                  break;

 

                                        case "name2":

                                                  gotoAndStop(3);

                                                  break;

                              }

                    }

Participant
April 26, 2012

hi, thanks for reply

i have try your code and it keep show

Error 1013: The private attribute may be used only on class property definitions.

refer to "private function onSubmit(e:MouseEvent):void"

please help

Thank you so much.

_spoboyle
Inspiring
April 26, 2012

sorry i forget these things when people work directly ont he timeline, just remove the word private

stop();

submit.addEventListener(MouseEvent.CLICK, onSubmit);

function onSubmit(e:MouseEvent):void

                    {

                              switch (yourname.text)

                              {

                                        case "name1":

                                                  gotoAndStop(2);

                                                  break;

                                        case "name2":

                                                  gotoAndStop(3);

                                                  break;

                              }

                    }