我在点击事件中创建了许多文本字段。现在我想在任何选择的textField中更改textformat。但textformat应用了最新的创建文本字段。我试过跟随
function _txtbtn(e:*):void
{
myText = new TextField();
mc3 = new MovieClip();
myText.text = "text...";
myFormat.font = "Arial";
myFormat.color = txt_color()
myText.setTextFormat(myFormat);
mc3.addChild(myText);
addChild(mc3);
mc3.x = _can.x;
mc3.y = p;
p= mc3.y+mc3.height+10;
mc3.addEventListener(MouseEvent.MOUSE_DOWN,_select)
}
function _select(e:MouseEvent):void
{
tool_stage.combo.addEventListener(Event.CHANGE,_font);
}
function _font(e:Event):void
{
format.font = tool_stage.combo.selectedLabel;
myText.setTextFormat(format);
}
答案 0 :(得分:0)
编辑回答:
function _font(e:Event):void
{
format.font = tool_stage.combo.selectedLabel;
var mc:MovieClip = e.target as MovieClip;
(mc.getChildAt(0) as TextField).setTextFormat(format);
}