Flash AS3 settings File box focus method
Lash files and ActionScript files should be placed in the same directory, and note that the ActionScript file name is the class name, in the Flash file's Properties panel class to fill in the focus.
Package {
Import Flash.display.Sprite;
Import Flash.text.TextField;
Import Flash.text.TextFieldType;
Import flash.events.MouseEvent;
public class Main extends Sprite {
Public Function Main () {
var Field:textfield = new TextField ();
Field.border = true;
Field.background = true;
Field.type = Textfieldtype.input;
AddChild (field);
var button:sprite = new Sprite ();
Button.graphics.lineStyle ();
Button.graphics.beginFill (0xFFFFFF);
Button.graphics.drawRect (0, 0, 100, 50);
Button.graphics.endFill ();
Button.addeventlistener (Mouseevent.click, OnClick);
BUTTON.Y = 100;
AddChild (button);
}
Private Function OnClick (event:mouseevent): void {
Stage.focus = TextField (getchildat (0));
}
}
}
Set the space text to the focus code
Package {
Import Flash.display.Sprite;
Import Flash.text.TextField;
Import Flash.text.TextFieldType;
Import flash.events.MouseEvent;
public class Main extends Sprite {
Public Function Main () {
var Field:textfield = new TextField ();
Field.border = true;
Field.background = true;
Field.type = Textfieldtype.input;
AddChild (field);
var button:sprite = new Sprite ();
Button.graphics.lineStyle ();
Button.graphics.beginFill (0xFFFFFF);
Button.graphics.drawRect (0, 0, 100, 50);
Button.graphics.endFill ();
Button.addeventlistener (Mouseevent.click, OnClick);
BUTTON.Y = 100;
AddChild (button);
}
Private Function OnClick (event:mouseevent): void {
Stage.focus = null;
}
}
}
Set the text content and set it to the selected state
Package {
Import Flash.display.Sprite;
Import Flash.text.TextField;
public class main extends Sprite {
public function main ( ) {
&nbs p; var Field:textfield = new TextField ( );
stage.focus = field; //Set The focus to the text field
& nbsp; Field.text = "This is example text"; //Set The text value
; field.setselection (0, 0);
Trace (Field.caretindex);
addChild (field);
}
}
}