Setting focus on a Flex app after its loaded

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml&#8221;
layout=”absolute” creationComplete=”onLoad(event)”>

<mx:Script>
<![CDATA[
import flash.external.ExternalInterface;

private function onLoad(event:Event):void {
ExternalInterface.call(‘function browserFocus(){document.getElementById(\’PopUpWindow\’).focus();}’);
ExternalInterface.call(‘browserFocus’);
this.uname.setFocus();
}
]]>
</mx:Script>

<mx:VBox paddingTop=”100″>
<mx:HBox>
<mx:Label text=”Username:” />
<mx:TextInput id=”uname” />
</mx:HBox>
<mx:HBox>
<mx:Label text=”Password:” />
<mx:TextInput id=”pwd” displayAsPassword=”true” />
</mx:HBox>
</mx:VBox>
</mx:Application>

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