0

可能重复:
更改 AS3 中任何选定文本字段的格式?

我在单击事件中创建了许多文本字段。现在我想在任何选择的文本字段中更改文本格式。但是 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);
} 
4

1 回答 1

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);
} 
于 2013-02-02T12:26:50.553 回答