/ Published in: ActionScript 3

How To Set Focus on UIComponent
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="246" height="76"> <mx:Script> <![CDATA[ import mx.core.UIComponent; public function setFocusTo(object:UIComponent):void { object.setFocus(); } public function drawFocusTo(object:UIComponent):void { object.setFocus(); object.drawFocus(true); } ]]> </mx:Script> <mx:Button x="10" y="10" width="226" label="my button" id="myButton" /> <mx:Button x="10" y="42" label="set focus" click="setFocusTo(myButton)"/> <mx:Button x="103" y="42" label="set and draw focus" click="drawFocusTo(myButton)"/> </mx:Application>
Comments
