문제

This is not a big deal, but I'm wondering if I discovered a bug in AS3. The following code works fine (trackName is a TextField):

trackname.defaultTextFormat = format;
trackname.text = "   " + name;
trackname.width = width;
trackname.height = height;
trackname.textColor = color;
trackname.border = true;
trackname.x = x;
trackname.y = y;

However, if I assign the defaultTextFormat at the end:

trackname.text = "   " + name;
trackname.width = width;
trackname.height = height;
trackname.textColor = color;
trackname.border = true;
trackname.x = x;
trackname.y = y;
trackname.defaultTextFormat = format;

The format that is displayed is different- in fact, I'd guess it really is the default text format. Is there a separate thread that does the assignment, and therefore needs to be at the beginning to work?

도움이 되었습니까?

해결책

As per the documentation:

Use the TextField.defaultTextFormat property to apply formatting BEFORE you add text to the TextField, and the setTextFormat() method to add formatting AFTER you add text to the TextField.

The TextFormat properties are null by default because if you don't provide values for the properties, Flash Player uses its own default formatting.

Source: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextFormat.html

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top