这是你想要做的吗?
主.mxml:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
addedToStage="_onStaged(event)"
stateChangeComplete="_stateChangeCompleteHandler(event)">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:states>
<s:State name="c_main"/>
</s:states>
<fx:Script source="main.as" />
</s:WindowedApplication>
主要作为:
import flash.events.Event;
import mx.events.FlexEvent;
// ActionScript file
private function _onStaged(event:Event = null):void
{
this.currentState = "c_main";
}
protected function _stateChangeCompleteHandler(event:FlexEvent):void
{
trace("the state was set to "+this.currentState);
}