A simple AS3 textField focus example which adds a custom selection glow around the textfeild when it is selected…
Paste into frame 1
var glowOn = new GlowFilter(0x0099ff,1,4,4,2,1,false);
var glowOff = new GlowFilter(0x0099ff,0,4,4,2,1,false);
function init() {
for (var i = 0; i<4; i++) {
var mc = createTextField();
mc.name = "tf_"+i;
addChild(mc);
mc.x = 30;
mc.y = 30*(i+1);
mc.addEventListener(Event.CHANGE,traceValue);
mc.addEventListener(FocusEvent.FOCUS_IN,showSelected);
mc.addEventListener(FocusEvent.FOCUS_OUT,hideSelected);
}
}
function createTextField() {
var tf = new TextField();
var format = new TextFormat();
tf.defaultTextFormat = format;
tf.width =200;
tf.height =20;
tf.background = true;
tf.border = true;
tf.type = TextFieldType.INPUT;
return tf;
}
function traceValue(e:Event) {
trace(e.target.name + ": " + e.target.text);
}
function showSelected(e:FocusEvent) {
e.target.filters = [glowOn];
}
function hideSelected(e:FocusEvent) {
e.target.filters = [glowOff];
}
init();