I have an application which has two states - 
1. Login state 
2. Application state. 

First the application has no child elements but has two states as 
above. once the user types the url I authenticate the user from the 
active directory and if the authentication fails login state is 
displayed giving the user a chance to enter the credentials 
manually. Once the login is authenticated I move the user from login 
state to application state and initialize the application from the 
init method() call under the event initialize()  where the data will 
be fetched to populate the application state. 

After working on the application state when once the session
expires i reset the application from application state to to login
state. and after that if the user enters the credentials and they 
are validated and I set the application again from login state to 
application state. At this point it is not calling the
init() method of the application state. Means it just displays the
previously created state with the previous data. what I want is when
ever I move to login state I should destroy the children in the
application state and when ever I login again the application state
should get created again freshly so that it fires an initialize 
event and init() method is called.

The code snippet i tried is :

<mx:Application creationComplete=init()">

private function init():void {
// Code to display login state. or silent login to application state
if authenticated from Active directory.
}

<mx:states>
<mx:State name="LoginState">
<mx:AddChild position="lastChild">
<component:LoginView id="loginView" x="0" y="0" width="100%"
height="100%">
</component:LoginView>
</mx:AddChild>
</mx:State>
<mx:State name="ApplicationState">
<mx:AddChild position="lastChild">
<component:CoreApplication id="applicationView" x="0" y="0"
width="100%" height="100%">
</component:CoreApplication >
</mx:AddChild>
</mx:State>
</mx:states>

I tried setting applicationView to null in the EnterState, Activate
events of the LoginState but failed to destroy the application View. 
I
even tried <mx:RemoveChild in the login state but it is not 
destroying
the application view object and creating it again. it just removes it
from view and adds it back the same object.

Can some body pleas help!!!

Reply via email to