3/1/2011 1:43:14 AM
Title:
101 access property of parent from child component fash builder
hi all,
very basic Q for flash builder -> air app ->
|-mainapp.mxml
|-components.master.mxml
|-com.xlab.mca.mytest.as
{not full code}
in the mainapp.mxml
xmlns:xtra="components.*
<xtra:master>
</xtra:master>
in master.mxml I have a text input field
<s:TextInput x="106" y="72" id="textinput1"/>
from an onclick I am calling an AS3 component
import com.xlab.mca.mytest; //THIS WORKS FINE
in the component mytest.as I have to get the value of the textinput
var ttt:String;
ttt = escape(FlexGlobals.topLevelApplication.textinput0.text);
if I have the textinput in the mainapp.mxml it works fine,
but how do I access the property if it is in a component.*
thx
Art
3/3/2011 3:54:54 AM
declare a variable in the main application from with in the component containing textbox set that variable with reference to that textbox on loading of that component. Now you can use that variable to refer to that textbox from any part of application.
i.e
in main application declare variable
private var textRef:TextBox;
inside component set the variable. Here myText is the textBox
FlexGlobals.topLevelApplication.textRef=myText;
Now you can get its value using thi from anywhere
FlexGlobals.topLevelApplication.textRef.text