• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Apr 26, 2012 Apr 26, 2012

Copy link to clipboard

Copied

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.

TOPICS
ActionScript

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 26, 2012 Apr 26, 2012

Copy link to clipboard

Copied

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;

                              }

                    }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 26, 2012 Apr 26, 2012

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 26, 2012 Apr 26, 2012

Copy link to clipboard

Copied

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;

                              }

                    }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 26, 2012 Apr 26, 2012

Copy link to clipboard

Copied

Hi thank you so much for helping^ ^

it works!!

but i have one more question

if some of my family enter the wrong name, how can i make it to go to another frame

in this way I can tell them try to enter the different name they are search again?

Thank you

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 26, 2012 Apr 26, 2012

Copy link to clipboard

Copied

you should use the default option in the switch statement

that way yourname contains something not in one of the case statements it will go to the default bit and execute teh code there

function onSubmit(e:MouseEvent):void

                    {

                              switch (yourname.text)

                              {

                                        case "name1":

                                                  gotoAndStop(2);

                                                  break;

                                        case "name2":

                                                  gotoAndStop(3);

                                                  break;

                                        default:

                                                  goToAndStop(you frame you want);

                                        break;

                              }

                    }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 26, 2012 Apr 26, 2012

Copy link to clipboard

Copied

It works! Thanks for helping me out !

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 27, 2021 Mar 27, 2021

Copy link to clipboard

Copied

LATEST

hi can i still join??

I tried to use the code but it can't switch frame

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines