I have a flex application that has a home button. I need to reset the ap开发者_高级运维plication when this button is clicked. I can't use navigateToURL or ExternalInterface.call("window.location.reload"); as its not acceptable to reload the swf file. Is the any other way to achieve this? Any help regarding this is much appreciated.
there's no way to reload a flex application from the application itself. You could call a javascript function that will reload the page. Have a look at this: http://livedocs.adobe.com/flex/3/html/help.html?content=passingarguments_4.html
There is this concept of states in Flex. What you would need to do is, keep two states, one at the initial stage(which is the state when the swf loads), and the other with which the user is interacting. So lets say you have two states: stat1,stat2
And whenever there is a click on home page, you should do the following: 1.take user to stat2. 2.Clone stat2 and copy the reference to stat1 for usage next time. 3.do the reverse the next time there is a click on home page.
Regards
Neeraj
You could have the bulk of your flex app as a Module. Load the module on initialize or whatever. To refersh, unload/reload the module. That would basically refersh the app
You would have to use a javascript function that will reload the swf file with addition parameter in the url or else it will reload the swf from cache. (http://abc.com/myswffile.swf?reload=12345). 12345 - this would a random number.
i think , your situation is asking for state management, see i am a flex developer, so i m resetting the screen on every click n everyday(space on the screen is always less),
Do you want to hide some of screen component's, when you click some buttonn on the screen (in swf), then you can make them visible=false and also includeInLayout=false, this will remove them from the memory as well,
<mx:states>
<mx:State name="login">
<mx:SetProperty target="{rpass}" name="visible" value="false" />
<mx:SetProperty target="{rpass}" name="includeInLayout" value="false" />
</mx:State>
<mx:State name="register">
<mx:SetProperty target="{rpass}" name="visible" value="true"/>
<mx:SetProperty target="{rpass}" name="includeInLayout" value="true"/>
</mx:State>
</mx:states>
Here i have two states, login and register, so when you click on register button, then your rpass filed gets displayed and vice versa, so you could make screen like this..
State model in flex3 is easy and if you are in flex4, then it's even more beautiful there,
hope this helps
Ankur
精彩评论