可能重复:
Change format of any selected textfield in AS3?将所选文本字段的更改格式在AS3
我创造的点击文本框很多我event.now想在任何选择文本框来改变的TextFormat。但是textformat应用了最新的创建文本框。我试图follwing
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);
}
首先,会发生什么吧,当你跑的?另外,'addChild(mc3)'应该在'mc3.addChild(myText)'之前。 – David
run is successfull.but我想格式化选定的textfield.this代码创建只有最后一个textField formate。 –