How do I change the application state in code, using a variable? when I provide a static string it works fine, but not with a variable.
For example, this works: (parent as mx.core.Application).currentState= 'history'
And this does not: (parent as mx.core.Application).currentState= @data
Yes, I know that @data is being populated, as I print it in an alert box. And yes, I have already tried "currentState = @data" and "currentState = '@data'. Sadly, they did not work.
Here is the menu object:
<mx:MenuBar id="mnuMain" labelField="@label" itemClick="menuHandler(event);">
<mx:XMLList>
<menuitem label="File">
<menuitem label="Exit" data="exit" />
</menuitem>
<menuitem label="View">
<menuitem label="Home" data="home" />
<menuitem label="Monitor" data="impmon" />
<menuitem label="History" data="history" />
<menuitem label="Tables" data="tables" />
<menuitem label="Schema View" data="schema" />
</menuitem>
</mx:XMLList>
</mx:MenuBar>
Here is the handler:
private function menuHandler(event:MenuEvent):void {
var newstate:String;
newstate = @data.toString();
(parent as mx.core.Application).currentState = newstate;
}