@Gerry,
Thank for the reply.
I did set the focus like that, but no correct result?
Any suggestions?
Cheers
Cor
<AS FILE>
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class KeyboardEventTextInput extends Sprite {
private var inputTextField:TextField;
public function KeyboardEventTextInput() {
inputTextField = createTextField(10, 45, 100, 20);
inputTextField.maxChars = 40;
inputTextField.wordWrap = true;
inputTextField.type = TextFieldType.INPUT;
addChild(inputTextField);
stage.focus = inputTextField;
inputTextField.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
inputTextField.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
inputTextField.addEventListener(Event.CHANGE,
changeHandler);
}
private function createTextField(x:Number, y:Number,
width:Number, height:Number):TextField {
var result:TextField = new TextField();
result.x = x;
result.y = y;
result.width = width;
result.height = height;
result.background = true;
result.border = true;
addChild(result);
return result;
}
private function keyDownHandler(e:KeyboardEvent):void {
trace("keyDownHandler: " + e.keyCode);
trace("ctrlKey: " + e.ctrlKey);
trace("keyLocation: " + e.keyLocation);
trace("shiftKey: " + e.shiftKey);
trace("altKey: " + e.altKey);
}
private function keyUpHandler(e:KeyboardEvent):void {
trace("keyUpHandler: " + e.keyCode);
}
private function changeHandler(e:Event):void {
trace("changeHandler: " +e.target.text);
}
}
}
</AS FILE>
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Gerry
Sent: zaterdag 28 februari 2009 15:03
To: Flash Coders List
Subject: Re: [Flashcoders] InputTextField issue
You can look up focus (stage.focus = txtName; ), that will allow you
to set which textfield has focus and for tabbing use
tabIndex like this.
txtName.tabIndex = 0;
txtEmail.tabIndex = 1;
txtAddress.tabIndex = 2;
txtCity.tabIndex = 3;
-Gerry
On Feb 28, 2009, at 3:19 AM, Cor wrote:
> Hi Keith,
>
> I think I have put it wrong in my question.
> When running in the IDE is discards several, like: q,e,r,t, but the
> w is
> accepted.
> When I run in in html it accepts nothing.
>
> But in both cases when I first click the textfield the give it the
> focus it
> works as expected.
>
> So my problem really is: How to give the textfield the focus on start?
> And additional when I have a second textfield, how can I make is
> change from
> one to the other using the TAB key?
>
> Kind regards
> Cor
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.0.237 / Virus Database: 270.11.4/1976 - Release Date: 02/27/09
13:27:00
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders