Just to clear something up, when you say you're using an "inline" function, do you mean that you've declared it in a <mx:Script> tag, or did you write the function directly into the click event in the button tag? I'm going to assume the prior, correct me if I'm mistaken.
The easiest way to handle states is to use the currentState property of the object in question. Changing this property will change the state directly.
For example, you can set the starting state of your application in a variable:
<mx:Script>
<![CDATA[
[Bindable]
var applicationState : String = "first_state";
]]>
</mx:Script>
- <mx:Script>
- <![CDATA[
-
- [Bindable]
- var applicationState : String = "first_state";
-
- ]]>
- </mx:Script>
Now, you want to bind this value to the application's state like so:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
currentState="{applicationState}">
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="absolute"
- currentState="{applicationState}">
Notice how I've used data binding to bind the state of the application to the variable "applicationState". Now, to change the state of the application, you simply change this variable to the new state in your function:
private function getit() : void
{
// your other code here...
...
...
applicationState = "new_state";
}
- private function getit() : void
- {
- // your other code here...
- ...
- ...
- applicationState = "new_state";
- }
Good programming practice is to declare all the possible states as static constants that can easily be switched out.
The Beer Monocle. Classy.