单击按钮增加文本大小

Increase size of text on click on button

如何在 AS3、Adobe flash 中单击按钮时增加动态文本的大小? 我有一个动态文本框(实例名称是 damodara)。

我尝试使用以下代码,但没有成功。

text_big.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(e:MouseEvent):void
{
    damodara.size +=  4;
}

如果你能帮助我,我会很高兴。

您不能增加文本的大小,而是在单击按钮时增加字体大小,然后就可以了。

textFormat = youtTextField.getTextFormat();
textFormat.size = int(textFormat.size)-1;
youtTextField.setTextFormat(textFormat);

像这样使用集合setTextFormat

首先,你需要有一个TextFormat对象。像这样:

var tf:TextFormat = new TextFormat();

然后像这样设置它的属性:

tf.size = 5; // or whatever you want here

然后将此格式应用于您的文本:

myTextField.setTextFormat(tf);

然后,在您发布的代码中,将 size+=5 替换为 damodara.setTextFormat(tf);

然后要将其改回,您可以使用不同的 TextFormat 和不同的 size 属性 或更改 size 属性 的 this TextFormat 并再次应用格式 setTextFormat