dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Applying horizontal scale to squish a TextField

  1. #1
    Multitouch Aficionado
    Join Date
    Mar 2006
    Posts
    275

    Applying horizontal scale to squish a TextField

    How can I transform the actual glyphs of a TextField? If I use scaleX or transform.matrix.scale, the text box shrinks, but the text itself stays the same size.

    I'm trying to do something like this:
    textField.scaleX = textField.width/textField.textWidth;
    to force a String to fit into a specified area, like in Illustrator. I want the width to be whatever I set it to, but the whole String needs to scale to fit in the box.

    Thanks.

  2. #2
    Multitouch Aficionado
    Join Date
    Mar 2006
    Posts
    275
    A bit more convoluted than a TextField, but this seems to work:

    Code:
    var fontDescription = new FontDescription('Myriad Pro');
    var format = new ElementFormat(fontDescription, 18, 0x003366);
    var textElement = new TextElement('This is some text');
    textElement.elementFormat = format;
    var textBlock = new TextBlock();
    textBlock.content = textElement;
    var textLine = textBlock.createTextLine();
    addChild(textLine);
    textLine.y = textLine.height;
    textLine.scaleX = .5;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center