正如标题所说,我需要找到一种方法来执行此代码,但要以更有效的方式。
if (texten.texten.numLines < 3)
{
texten.texten.y = 0;
texten.texten.height = 118;
}
if (texten.texten.numLines == 3)
{
texten.texten.y =- 59;
texten.texten.height = 177;
}
else if (texten.texten.numLines == 4)
{
texten.texten.y =- 118;
texten.texten.height = 236;
}
else if (texten.texten.numLines == 5)
{
texten.texten.y =- 177;
texten.texten.height = 295;
}
else if (texten.texten.numLines == 6)
{
texten.texten.y =- 236;
texten.texten.height = 354;
}
else if (texten.texten.numLines == 7)
{
texten.texten.y =- 295;
texten.texten.height = 413;
}
else if (texten.texten.numLines == 8)
{
texten.texten.y =- 354;
texten.texten.height = 472;
}
else if (texten.texten.numLines == 9)
{
texten.texten.y =- 413;
texten.texten.height = 531;
}
else if (texten.texten.numLines == 10)
{
texten.texten.y =- 472;
texten.texten.height = 590;
}
如您所见,此代码将降低文本字段(texten.texten 是我在movieClip 中的文本字段)并提高它的高度(每当添加新行时使文本向上跳)