开发者

Refreshing a Flex component

Is there a way to refresh a component or an application back to its initial state? I have an accordion navigator that stays on the most recently selected index even if I log out. Right now, my log out function takes me back to the login page which is at state(1). If I log back in and go i开发者_StackOverflownto the accordion, it is on the last tab I had viewed.

I would like to be able to clear any data from the controls inside the nav and reset the nav back to its default. I thought something like,

public function logout():void{
  currentState = "NotLoggedIn"
  myAccordion.initialize(); }

would work but nothing happens. This is done in Flex 4.

I know I can make a huge loop clearing each control individually and setting the selectedIndex of the accordion to 0. I was hoping for a simpler solution.


It depends what you mean by "State".

If you have implemented states in your Flex Component, you can revert back to a previous state using:

component.currentState = 'myInitialState';

If you are not talking about states, explicitly, but rather about the internal values of the properties of the component, then Flex does not keep a history of those property values. You can keep track of them yourself and reset them in the manually.

Once you do that, your component will be, effectively, in the initial state.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜