How To Set Focus on UIComponent

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml&#8221;
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>

Source : http://www.flexer.info/2008/06/06/how-to-set-focus-on-uicomponent/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s