Question...
I've got a simple form with a label, textinput, textarea, and button. The text in the textinput is appended to the text in the textarea when the button is pressed. The problem is that I can't access the textinput or textarea as expected. Below is my code. I got it to work by targeting it with _parent, but that seems unnecessary. What am I doing wrong?
Thanks in advance.
Actionscript:
import mx.controls.*;
class Test extends MovieClip
{
private var input_lbl:Label; // Just a label for the input textbox
private var input_ti:TextInput; // input field for entering text
private var output_ta:TextArea; // text area for displaying the entered text
private var go_btn:Button; // Button that triggers the event
function Test()
{
this.init();
}
private function init():Void
{
go_btn.onRelease = whenGoButtonClicked;
}
private function whenGoButtonClicked():Void
{
// This works, but I shouldn't have to do it this way
_parent.output_ta.text += _parent.input_ti.text + ", ";
// This doesn't work, and I don't know why
//output_ta.text += input_ti.text + ", ";
}
}
Thanks in advance.
Actionscript:
import mx.controls.*;
class Test extends MovieClip
{
private var input_lbl:Label; // Just a label for the input textbox
private var input_ti:TextInput; // input field for entering text
private var output_ta:TextArea; // text area for displaying the entered text
private var go_btn:Button; // Button that triggers the event
function Test()
{
this.init();
}
private function init():Void
{
go_btn.onRelease = whenGoButtonClicked;
}
private function whenGoButtonClicked():Void
{
// This works, but I shouldn't have to do it this way
_parent.output_ta.text += _parent.input_ti.text + ", ";
// This doesn't work, and I don't know why
//output_ta.text += input_ti.text + ", ";
}
}
