Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need helpwith Actionscript Fonts 1

Status
Not open for further replies.

avinsinanan

Programmer
Jul 14, 2002
92
TT
Hi I need to know how to set the font in Actionscript

I have the followingf Text -

text = "Whats Ups";

How do i set the font of this text to lets say Arial?

Thanks for your help
 
You can set fonts and decoration via actionscript with the textfield and textformat objects like this:

//create a textfield dynamically
this.createTextField("field", 1, 10, 10, 150, 30);
//content of the field
field.text = "Dynamic text for testing";
//the size, face etc
style = new TextFormat();
style.bold = true;
style.size = 16;
style.font = "Arial";
//apply the style to the field
field.setTextFormat(style);

...or you can have a dynamic textfield with html formatting switched on and use standard HTML font tags to alter the appearance of the text.

field.htmlText=&quot;<font face='arial'>arial</font> <font face='courier'>courier</font>&quot;
 
Hi thanks,

But is there is simplier way?

I was hoping for something along the lines -

text = &quot;Whats Ups&quot;;
text.font = &quot;Arial&quot;;

You see am helping someone with a project and there code is layed out a certain way already. So I was wondering if there is a simplier way?

Thanks Again
 
no simpler way.

keep in mind, also, that when you use the TextFormat object to define a font, you should use a font that you know will be available on all client machines, OR, embed it, OR use one of the flash player's built in fonts (&quot;_sans&quot;,&quot;_typewriter&quot;, etc.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top