?

Log in

I've got a simple form with a label, textinput, textarea, and button.… - o9soft.DEV [entries|archive|friends|userinfo]
o9software development forum

[ website | o9software's development server ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

[Sep. 29th, 2005|03:48 pm]
o9software development forum

o9soft

[daitengu]
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 + ", ";
}
}
linkReply

Comments:
[User Picture]From: o9software
2005-10-01 09:37 pm (UTC)
Well i havnt use actionscript in over a year but, from what i remember about its OOP handling the line that isnt working theoretically should...

Some debugging ideas:

See if it works with static text, for example try the line:
output_ta.text += "FooBar";
or
output_ta.text = "FooBar";

Try moving that statement to another method, like the constructor and see if that works. Basically see if its a problem with the methods access to the variable.
You might also try changing the access levels of both that method and that variable to public just for the hell of it. (ActionScripts built in classes have loads of public member variables... hell the 'text' member is an example right off. So conforming to true encapsulation isnt really important in actionscript anyways.)

If you come up with some more information from trying out some different debugging steps, let me know. If I have more idea from that I would be glad to help. Also if somehow I end up with some free time (not very likely) I can fire up flash sometime and see if I can replicate your problem.

Hope this helps.

Richard
o9software - Lead Programmer
(Reply) (Thread)