I got the first error figured out, but I have run into the same problem
I had before.

When a user needs to add a new vendor, they are taken to the state on
the parent application called vendorAdd. When they click save or close,
it should return them to the previously called state. But it does not
work on the parentApplication level. This is the code I am testing.

vendorAdd.mxml-
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas width="100%" height="100%"
currentStateChanging="setOldState(event)"
xmlns:mx="http://www.adobe.com/2006/mxml"; xmlns="*">
<mx:Script source="as/vendorAdd.as" />
     <mx:Panel x="0"
         title="" y="0" width="100%" height="100%">
         <mx:Canvas width="100%" height="100%" id="canvas1">
         </mx:Canvas>
         <mx:ApplicationControlBar x="0" width="100%"  height="35">
             <mx:Button click="returnState()" label="Save"/>
             <mx:Button label="Reset"/>
         </mx:ApplicationControlBar>
     </mx:Panel>
</mx:Canvas>

vendorAdd.as -

// imports
  import mx.events.*;
     // Sets Previous State Var
      public var prevState;


         // Function to set previous state
         public function setOldState(evt:StateChangeEvent):void

         {
                prevState = evt.oldState;
         }
         // Returns User to Previous State
         public function returnState()
         {
             parentApplication.currentState = prevState;
         }


--- In [email protected], "Jeremy Rottman" <[EMAIL PROTECTED]>
wrote:
>
> this is code that I am trying. But it gives me this error.
>
> Implicit coercion of a value of type 'flash.events:MouseEvent' to an
> unrelated type 'mx.events:StateChangeEvent
>
> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml";
> currentStateChanging="setOldState(event)" width="907" height="519"
> xmlns="*">
> <mx:Script>
>  <![CDATA[
>    import mx.events.*;
>
>         public var prevState;
>
>
>
>         public function setOldState(evt:StateChangeEvent):void
>
>         {
>
>                 prevState = evt.oldState;
>
>         }
>  ]]>
> </mx:Script>
>  <mx:states>
>   <mx:State name="test">
>    <mx:AddChild position="lastChild">
>     <mx:Button x="173" y="454" click="setOldState(event)"
label="Button"/>
>    </mx:AddChild>
>   </mx:State>
>  </mx:states>
>  <mx:Button x="31" y="454" click="currentState = 'test'"
label="Button"/>
> </mx:Canvas>
>
>
> --- In [email protected], "Ashish Goyal" agoyal@ wrote:
> >
> > There is typo:
> >
> > "and in the event handler set some variable to the event.OldState"
> >
> > Its event.oldState (lower case o)
> >
> > -Ashish
> >
> >
> > -----Original Message-----
> > From: [email protected] [mailto:[EMAIL PROTECTED]
On
> > Behalf Of Ashish Goyal
> > Sent: Monday, April 10, 2006 3:03 PM
> > To: [email protected]
> > Subject: RE: [flexcoders] Calling previous state
> >
> > You can use newState and oldState properties of the
StateChangeEvent.
> >
> > There is another event "currentStateChanging" which you can define
on
> > the application tag and in the event handler set some variable to
the
> > event.OldState.
> >
> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> > currentStateChanging="setOldState(event)">
> >
> > In the script block:
> >
> >  import mx.events.*;
> >  public var prevState;
> >
> >  public function setOldState(evt:StateChangeEvent):void
> >  {
> >   prevState = evt.oldState;
> >  }
> >
> > You can set your currentState to prevState to go to the previous
state.
> >
> > Hope this helps.
> >
> > -Ashish
> >
> >
> > -----Original Message-----
> > From: [email protected] [mailto:[EMAIL PROTECTED]
On
> > Behalf Of Jeremy Rottman
> > Sent: Monday, April 10, 2006 2:00 PM
> > To: [email protected]
> > Subject: [flexcoders] Calling previous state
> >
> > I am working on my app, and I have run into a situation where I need
> > change states and then when a user saves it takes them back to thier
> > previous state. Is there something like previousState?
> >
> >
> >
> >
> >
> >
> > --
> > Flexcoders Mailing List
> > FAQ:
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives:
> > http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > --
> > Flexcoders Mailing List
> > FAQ:
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives:
> > http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > Yahoo! Groups Links
> >
>







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to