tags:

views:

154

answers:

1

Hi, Does anyone know how i can reset/reinitialize a state in flex 3?

Let's say I have the following code:

<mx:states>
    <mx:State name="Scene1">
        <mx:AddChild>
            <Scenes:Scene1 id="scene1"></Scenes:Scene1>
        </mx:AddChild>
    </mx:State>
    <mx:State name="Scene2">
        <mx:AddChild>
            <Scenes:Scene2 id="scene2" models="{models}"></Scenes:Scene2>
        </mx:AddChild>
    </mx:State>
</mx:states>

And every time i go from 1 to 2 or 2 to 1, I wan't to recreate the entire State.

A: 

I am not certain this is what you are looking for, but this code will render the states you have defined above:

// this shows Scene1
this.currentState = "Scene1";

// this shows Scene2
this.currentState = "Scene2";

Is that what you were looking for?

OneNerd
No, that just changes the state (and creates it the first time it's selected). I wan't to recreate it the next time i change states.
oletk
By recreate, I guess you mean clear out any data entered by the user? If that's the case, the only way I know is to write code to clear it all out after setting the currentState ~ perhaps someone else knows a quicker way.
OneNerd
Yeah, I've been thinking about doing that, but it would be so much easier and so much less work if there was another way.Thanks for your answers!
oletk