• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • Last Modified:

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
0
Donelson
Asked:
Donelson
  • 6
  • 6
1 Solution
 
Aneesh ChopraCommented:
Hi,

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

Rgds
Aneesh
0
 
DonelsonAuthor Commented:
0
 
DonelsonAuthor Commented:
Does the autoSize disable the font size ?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Aneesh ChopraCommented:
Link to file is broken.......
0
 
Aneesh ChopraCommented:
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
0
 
DonelsonAuthor Commented:
Sorry, try my link now.

William
0
 
Aneesh ChopraCommented:
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
0
 
DonelsonAuthor Commented:
Sorry! Very sorry!

Didn't have complete file set....

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

William


0
 
Aneesh ChopraCommented:
Ok, got the issue..

1.
setTextFormat is a method of textField not movieClip..
theTitle,dropShadowA & dropShadowB are actually movieClips,,
textfields are inside them..
here is the correct code...
---------
theTitle.theText.setTextFormat(style_fmt);
dropShadowA.theText.setTextFormat(style_fmt);
dropShadowB.theText.setTextFormat(style_fmt);
--------


2.
you must set the text first  and then use the setFormat
---------
niceTitle.setTitle(theTitle, Stage.width/2, 60, 600);
niceTitle.setTextHeight(40);
//
smallTitle.setTitle("The Knights of the Round Table vowing to seek the Sangreal", Stage.width/2, 82);
smallTitle.setTextHeight(12);
---------


Rgds
Aneesh
0
 
Aneesh ChopraCommented:
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
0
 
DonelsonAuthor Commented:
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);

0
 
DonelsonAuthor Commented:

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now