How to get id value of Main.mxml file to CustomPanel.mxml file?

alamflex used Ask the Experts™
I have a method in CustomPanel.mxml and i need to use id which is available in Main.mxml

Below is my sample code

<local:CustomDividedBox id="div1">

private function xxxx(){
div1.state = (div1.state == CustomDividedBox.COLLAPSE ? CustomDividedBox.EXPAND : CustomDividedBox.COLLAPSE);


Plz provide some sample code.

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2011
I think I understand what you want, looks like you are trying implementing toogle feature in CustomDividedBox what I think is good idea. So, add this function into your

public function toggle():void{
   state = (state == CustomDividedBox.COLLAPSE ? CustomDividedBox.EXPAND : CustomDividedBox.COLLAPSE);

Now you can call ths function anytime and apply for any Divided boxes

private function contextMenuItem_propertiesSelect(evt:ContextMenuEvent):void {

if your Custompanel is used as component in Main.mxml then you could pass a reference to the div1 CustomDividedBox to your Custompanel.

Sample code for Main.mxml
<local:CustomDividedBox id="div1"/>
<local:Custompanel id="panel" box="{div1}"/>

Open in new window

You need to add a variable "box" to your Custompanel class and use this in your xxxx function:
			import CustomDividedBox;
			public var box:CustomDividedBox;
			private function xxxx():void {
				box.state = (box.state == CustomDividedBox.COLLAPSE) ? 
								CustomDividedBox.EXPAND : 

Open in new window

Just a question: are you using states in your CustomDividedBox and want to change the state of the box? Then you would have to use the property box.currentState instead of box.state.


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial