How To Set Focus on UIComponent


/ Published in: ActionScript 3
Save to your folder(s)

How To Set Focus on UIComponent


Copy this code and paste it in your HTML
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  3. layout="absolute" width="246" height="76">
  4. <mx:Script>
  5. <![CDATA[
  6. import mx.core.UIComponent;
  7. public function setFocusTo(object:UIComponent):void
  8. {
  9. object.setFocus();
  10. }
  11. public function drawFocusTo(object:UIComponent):void
  12. {
  13. object.setFocus();
  14. object.drawFocus(true);
  15. }
  16. ]]>
  17. </mx:Script>
  18. <mx:Button x="10" y="10" width="226"
  19. label="my button" id="myButton" />
  20. <mx:Button x="10" y="42"
  21. label="set focus" click="setFocusTo(myButton)"/>
  22. <mx:Button x="103" y="42"
  23. label="set and draw focus" click="drawFocusTo(myButton)"/>
  24. </mx:Application>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.