Reputation: 1160
i have main Application which is Spark component
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
minWidth="955" minHeight="600" initialize="initApp();" xmlns:layout="com.zycus.workflow.editor.view.layout.*">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<layout:LeftPanel id="leftPanel">
</layout:LeftPanel>
</s:application>
What i need is i want to access leftpanel of mail application in Asction Script class
How can i do it?
Upvotes: 0
Views: 467
Reputation: 976
You have a couple of options, I simplified your code, and fixed a typo and removed references to objects you didn't include. As you can see in the code below, you can go all the way to the topLevelApplication, or in this case, just reference the id you have defined.
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
minWidth="955" minHeight="600" initialize="initApp(event)" >
<fx:Script>
<![CDATA[
import mx.core.FlexGlobals;
import mx.events.FlexEvent;
protected function initApp(event:FlexEvent):void
{
// Either from the top, if in another class, or ...
var pnl:Panel = Panel(FlexGlobals.topLevelApplication.leftPanel);
pnl.width = 500;
// Directly, since we are in this context.
leftPanel.width = 500;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Panel id="leftPanel">
</s:Panel>
</s:Application>
This example runs in Flash Builder. This should work regardless of the actual content of your LeftPanel.
Upvotes: 1