• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1905
  • Last Modified:

Flex 4.5 Spark textInput get focus

Hi Experts,

I have a little test app that I am playing with and when it loads in the browser I would like the textinput box to have focus so I can start typing and the characters and they appear in the textbox without first clicking the textbox.

My current code brings focus to the textinput but doesn't allow me to start typing without first clicking the text box.  I just want to load the page and if I immediately begin typing, the characters appear in the textbox.

How can I correct this?


<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
			   width="240" minWidth="240" minHeight="600" pageTitle="test app" creationComplete="creationCompleteHandler()">
			import spark.components.Label;
			private function creationCompleteHandler():void
			protected function button1_clickHandler(event:MouseEvent):void
				// TODO Auto-generated method stub
				var barcodeEcho:Label = new Label();
				barcodeEcho.text = scannedBarcode.text;
		<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:BorderContainer id="container" height="300" width="240" borderStyle="inset"
			borderColor="#cccccc" borderWeight="4">
	<s:TextInput id="scannedBarcode"/>
	<s:Button label="Echo Barcode" click="button1_clickHandler(event)"/>


Open in new window

3 Solutions
You cant, the flash container needs a click to get focus first. Its a common questions, there are work arounds for some browsers but not all.
You could try this which claims to work in all browsers
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Using the dynamic publishing method of SWFObject claims to avoid the click-to-activate stuff for flash. Mabe this helps?
http://code.google.com/p/swfobject/wiki/documentation (read the "Should I use the static or dynamic publishing method?" section)
HelpNearMeAuthor Commented:
Still trying these solutions.. I'll be back soon.  Thanks
HelpNearMeAuthor Commented:
Thanks for the help.  I'm having some serious problems just getting flash to work on the handheld.  So I'm going to close this question.  Thanks again.

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now