While I've also suggested using these in the past, in the spirit of
loose coupling, the prefered method would be to dispatch an event, from
the component, that would trigger the drillDown method in the parent;
where the states are actually located.  This way the child doesn't know
or care about the parent and can be reused elsewhere.  This also
elliminates the need to maintain the state names in multiple classes;
should any name changes become necessary.  Basically, it's not best
practice to control a parent's state directly, from a child.

-TH

--- In [email protected], Charles Parcell <pokemonkil...@...>
wrote:
>
> Application.application.currentState = 'invoiceDetailsInfoPanel';
>
> or
>
> parentDocument.currentState = 'invoiceDetailsInfoPanel';
>
> Either of these work for you?
>
> Charles P.
>
>
>
> On Fri, May 8, 2009 at 4:05 PM, rdell123 rdell...@... wrote:
>
> > Is it possible to set the currentState from a function located in a
child
> > mxml file when the States are in the parent file?
> >
> > INVOICES.MXML
> > ---
> > <mx:Script>
> > <![CDATA[
> > private function drillDown(event:ListEvent):void {
> > if (currentState != "invoiceDetailsInfoPanel") {
> > currentState = 'invoiceDetailsInfoPanel';
> > } else {
> > currentState = '';
> > }
> > }
> > ]]>
> > </mx:Script>
> > <mx:DataGrid id="invoiceGrid" dataProvider="{model.data}"
> > doubleClickEnabled="true" itemDoubleClick="drillDown(event)">
> > <mx:DataGrid:columns>
> > <mx:DataGridColumn headerText="Invoice #"
> > dataField="agency"/>
> > </mx:DataGrid:columns>
> > </mx:Datagrid>
> > ---
> >
> > MAINFORM.MXML
> > ---
> > <mx:Canvas xmlns:invoice="com.vendor.invoice.*">
> > <mx:states>
> > <mx:State name="invoiceDetailsInfoPanel">
> > <mx:SetProperty target="{infoBoxInvoices}" name="height"
> > value="290"/>
> > <mx:AddChild relativeTo="{infoBoxInvoices}">
> > <mx:Canvas><mx:FormItem label="Vendor:"><mx:Label
> > text="Yahoo"/></mx:FormItem></mx:Canvas>
> > </mx:AddChild>
> > </mx:State>
> > </mx:states>
> > <mx:Canvas id="infoBoxInvoices" height="100">
> > <mx:FormItem label="Client:">
> > <mx:Label text="Nabisco"/>
> > </mx:FormItem>
> > </mx:Canvas>
> > <invoice:invoiceToolbar id="invoiceToolbarPanel"/>
> > </mx:Canvas>
> >
>



Reply via email to