Copy link to clipboard
Copied
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 ^^
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;
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
here,
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;
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
thank you very much! I got it now. It's really a big help to my thesis. Thank you very much!
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now