0
votes

I started on AS3 before 3 days, and i have written this code, but there's something wrong and i don't know which is the mistake.. Please help or Correct this! Thank you very much! Regards ValterZHD.

My code

var format:TextFormat = new TextFormat();
var myFont:Font = new (Times New Roman) ();
format.font = myFont.fontName;
message_mc.message_txt.defaultTextFormat = format; 
message_mc.message_txt.text = "You're lost in wilderness";
1
You're using the font name without quoting it, as if it was an object, which will result in a syntax error. - Eran Boudjnah
Thanks it worked but now in output says "TypeError: Error #1007: Instantiation attempted on a non-constructor. at Untitled_4_fla::MainTimeline/frame1()" - ValterZHD
You've used new without providing a constructor. (Times New Roman) is not a constructor. It's not even an object. "Times New Roman" would be a string. Right now, it's treating Times as an object... - Eran Boudjnah
Could you please tell me how to fix that error? Im sorry, im very new at AS3.. - ValterZHD

1 Answers

0
votes

There's no Font class in AS3. You only need to provide the font name to the TextFormat font property.

var format:TextFormat = new TextFormat();

format.font = "Times New Roman";

message_mc.message_txt.defaultTextFormat = format;

message_mc.message_txt.text = "You're lost in wilderness";