flash - Flex 3: How to change state in code, using a variable -
How do I change the application state in a code using a variable? When I provide a stable string it works fine, but not with a variable
For example, it works: (mx.core.Application as parent) .currentState = 'history'
And it is not: (Mother- Mx.core.Application as a father. Current date = @ data
Yes, I know that @ data is being populated, because I print it in a warning box. And of course, I have already tried on "currentState = @data" and "currentState = '@data. Sadly, they did not work.
Here is the menu object:
gt; & lt; / menuitem & gt; & lt; menuitem label =" view "& gt; menuitem label = "Home" data = "home" /> gt; & lt; menuitem label = "monitor" data = "Impn"> Lt; menuitem Force = "table" data = "tables" /> & gt; menuitem label = "schema view" data here is the handler:
Code> Personal Function Menhandler (Event: Menu Event): Zero {var newstate: String; newstate = @ data.toString (); (as parent Mx.core.Ap Plication) .currentState = newstate;}
Here's a quick example That's what I've picked:
& Lt; / Mx: state & gt; & Lt; Mx: state name = "print" & gt; & Lt; Mx: SetProperty Goal = "{label1}" name = "text" value = "Imman State" /> & Lt; / Mx: state & gt; & Lt; Mx: state name = "history" & gt; & Lt; Mx: SetProperty target = "{label1}" name = "text" value = "history state" /> & Lt; / Mx: state & gt; & Lt; Mx: state name = "table" & gt; & Lt; Mx: SetProperty target = "{label1}" name = "text" value = "Tables state" /> & Lt; / Mx: state & gt; & Lt; Mx: state name = "schema" & gt; & Lt; Mx: SetProperty target = "{label1}" name = "text" value = "schema state" /> & Lt; / Mx: state & gt; & Lt; / Mx: states & gt; & Lt; Mx: script & gt; & Lt ;! [CDATA [import Flash.ut ils.getQualifiedClassName; Import mx.events.MenuEvent; Private Function Menhandler (Event: Menu Event): Zero {trace ("clicked", string (event.item. @ Data)); CurrentState = String (event.item. @ Data); }] & Gt; & Lt; / Mx: script & gt; & Lt; Mx: MenuBar id = "mnuMain" label field = "@ label" item = "menuhandler (event)" & gt; & Lt; Mx: XMLList & gt; & Lt; Menuitem label = "file" & gt; & Lt; Menuitem label = "exit" data = "exit" /> & Lt; / MENUITEM & gt; & Lt; Menuitem label = "see" & gt; & Lt; Menuitem label = "home" data = "home" /> & Lt; Menuitem label = "monitor" data = "print" /> & lt; Menuitem label = "history" data = "history" /> & Lt; Menuitem label = "table" data = "table" /> & Lt; Menuitem label = "schema view" data = "schema" /> & Lt; / MENUITEM & gt; & Lt; / Mx: XMLList & gt; & Lt; / Mx: menubar & gt; & Lt; Mx: label horizontal center = "0" vertical center = "0" font seices = "30" fontEUEE = "bold" color = "#ffff" text = "default state" id = "label 1" & gt; & Lt; Mx: Filter & gt; & Lt; Mx: DropShadowFilter / & gt; & Lt; / Mx: filter & gt; & Lt; / Mx: label & gt; & Lt; / Mx: Applications & gt;
Comments
Post a Comment