header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
art vabderhoff
Points:0
Posts:0

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



1
bob_senior
Points: 1320
Posts:0
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




Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 0+6 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions