I know this is a simple question, but I haven't worked much with ActionScript...
I know how to create a text input field with Flash. I can create it on the stage and give it an instance name.
What is the code to capture the value of a text input field and display that value in a dynamic text field? How does this process differ between ActionScript 2.0 and 3.0?
It really depends when you want to update the dynamic textfield, with the input textfield's data.
If you want to update the dynamic text field once then try this:
//AS3
myDynamicTF.text = myInputFT.text;
//AS2
myDynamicTF._text = myInputFT._text;
If you want to update the dynamic textfield every time the user types in the input field, then in AS3 you need to listen for the TextField's Change event
//AS3
myInputFT.addEventListener(Event.CHANGE, changeHandler);
private function changeHandler(e:Event):void
{
myDynamicTF.text = myInputFT.text;
}
For AS2 you can just set the inputfield onChange method:
//AS2
myInputFT.onChanged = function(textfield_txt:TextField)
{
myDynamicTF._text = textfield_txt._text;
};
I was getting this error until I resaved my external .as file. Unlike stuff in the .fla, apparently Flash uses the last saved version of the .as file, not the current contents. Note: This is in Flash 8, so your mileage may vary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With