Link to home
Start Free TrialLog in
Avatar of Donelson
Donelson

asked on

set font size in dynamic text field

I can't believe this is so hard !!

//
// Routine to set the title & drop shadow font size
function setTextHeight(hei:Number):Void {
      hei = (hei == undefined) ? 24 : hei;
      //
      var style_fmt:TextFormat = new TextFormat();
      style_fmt.size = hei;
      //
      theTitle.setTextFormat(style_fmt);
      dropShadowA.setTextFormat(style_fmt);
      dropShadowB.setTextFormat(style_fmt);
}

The above code does not work.  HOW do I set the font size of a dynamic text field ?

Thanks
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

Hi,

It is working at my end.
Could you upload a sample FLA for reviewing.

Rgds
Aneesh
Avatar of Donelson
Donelson

ASKER

Does the autoSize disable the font size ?
Link to file is broken.......
I have uploaded a samlple FLA to show that your code is working fine
download it here....
http://s46.yousendit.com/d.aspx?id=0WD0IPWJNOCD1296S2OPK1Z9HD

Rgds
Aneesh
Sorry, try my link now.

William
unable to see any textbox in niceTitle_test.fla output..
I have already complied "niceTitle.swf"

Please test the package you have uploaded first and explain how can I replicate the issue.

Rgds
Aneesh
Sorry! Very sorry!

Didn't have complete file set....

Please download the niceTitle.zip again to get the full set of files.

William


ASKER CERTIFIED SOLUTION
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
here I have uploaded a updated version for you..
http://s24.yousendit.com/d.aspx?id=3F6R82OGXZSFD3MIDP1Q7L6KF0


I have just added a new parameter in "setTitle" function to set the textHeight.

Rgds
Aneesh
Aneesh.

1) Of course, I am so stupid:   theTitle.THETEXT.setText !!  I will remember this in future.

2) I have set a default text size inside the niceTitle.fla which then sets the text height BEFORE we determine the width of the field for scaling, etc.

So...
   // Set textHeight first, then draw titles
   niceTitle.setTextHeight(24);
   niceTitle.setTitle("This is a title", Stage.width/2, 60);
   niceTitle.setTitle("This is another title", Stage.width/2, 75);
   niceTitle.setTitle("This is a title", Stage.width/2, 90);

   /// Set another size and draw a smaller title
   niceTitle.setTextHeight(18);
   niceTitle.setTitle("This is a very long, very bad title to demonstrate....", Stage.width/2, 105);


(Of course, if you wanted them all on-screen at once, you'd load separate copies of the Swf's )