Pergunta

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?

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top