Actionscript – Flex – How to access component inside another component in MXML

actionscriptactionscript-3apache-flex

I have two components. One is called "InsideComp" and one is called "OutsideComp". OutsideComp has InsideComp as one piece of its component, and in my main MXML file, I have embedded an instance of OutsideComp. How do I access a public variable of InsideComp within my main MXML file?

In Actionscript, I could just do something like:
OutsideComp.InsideComp.valToChange = 5;

But I dont know how to do it in MXML. I know this is probably an easy question.

Best Answer

By setting the id property of the MXML component you effectively make it a public property accessible via dot-notation. "Accessing it via MXML" is sort of a trick question. You can use binding notation within an xml tag and bind the property to another property, or you can access it in your Script block in the normal AS3 fashion.

Related Topic