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

I need help for input-dynamic text

New Here ,
Jul 12, 2013 Jul 12, 2013

I'm currently developing a game and I have a problem with my  input-dynamic text. I'm trying to make my input text appear on other frame whenever I click the button, well, I tried some solutions that I saw here but it really did not well.
This is the first code I used:

stop();

function handleClick(pEvent:MouseEvent):void {

          var myfirstVariable = box1.text;

          welcome.text = "Welcome to the game " + myfirstVariable;

          }

          enter_button.addEventListener(MouseEvent.MOUSE_UP, handleClick);

it does work but only on one frame. and this is the code that i am trying to use now:

stop();

var enteredText:String;

   welcome.addEventListener(Event.CHANGE, updateString);

   function updateString(evt:Event){

       enteredText = welcome.text;

   }

   enter_button.addEventListener(MouseEvent.MOUSE_UP, handleClick);

and on the other frame:

stop();

enteredText = welcome_2.text;

thank you very much for the help ^^

TOPICS
ActionScript
964
Translate
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

correct answers 1 Correct answer

Community Expert , Jul 12, 2013 Jul 12, 2013

if you change frames and have another textfield on that new frame, you need to assign its text property:

//enteredText = welcome_2.text; <-comment out this line and use:

welcome_2.text=enteredText;

Translate
Community Expert ,
Jul 12, 2013 Jul 12, 2013

if you change frames and have another textfield on that new frame, you need to assign its text property:

//enteredText = welcome_2.text; <-comment out this line and use:

welcome_2.text=enteredText;

Translate
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 ,
Jul 12, 2013 Jul 12, 2013

oh i see. thank you very much! and another thing, I always get this undefined property enteredText on the other frame. Is it the source of the problem? since the input text is still not showing on the dynamic textbox.

Translate
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
Community Expert ,
Jul 13, 2013 Jul 13, 2013

are you seeing an error message?  if yes, copy and paste it after ticking file>publish settings>permit debugging. 

also copy and paste the code in the other frame and indicate the line of code mentioned in the error message.

Translate
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 ,
Jul 13, 2013 Jul 13, 2013

here,

error.jpg

first frame:

stop();

function handleClick(pEvent:MouseEvent):void {

          var enteredText:String;

   welcome.addEventListener(Event.CHANGE, updateString);

   function updateString(evt:Event){

       enteredText = welcome.text;

welcome.text = "Welcome " + enteredText;

   }

   }

          enter_button.addEventListener(MouseEvent.MOUSE_UP, handleClick);

second frame,

stop();

welcome_2.text=enteredText;

Translate
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
Community Expert ,
Jul 13, 2013 Jul 13, 2013

1. never nest named functions

2. don't make enteredText local to a function body

ie, use:

first frame:

stop();

           var enteredText:String;

function handleClick(pEvent:MouseEvent):void {

   welcome.addEventListener(Event.CHANGE, updateString);

}

   function updateString(evt:Event){

       enteredText = welcome.text;

welcome.text = "Welcome " + enteredText;

   }

enter_button.addEventListener(MouseEvent.MOUSE_UP, handleClick);

second frame,

stop();

welcome_2.text=enteredText;

Translate
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 ,
Jul 15, 2013 Jul 15, 2013

thank you very much! I got it now. It's really a big help to my thesis. Thank you very much!

Translate
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
Community Expert ,
Jul 15, 2013 Jul 15, 2013
LATEST

you're welcome.

Translate
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