Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8948863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:06:15+00:00 2026-06-15T13:06:15+00:00

I’m currently trying to set text size dynamically based on a stylesheet globally through

  • 0

I’m currently trying to set text size dynamically based on a stylesheet globally through a base font size variable. I’m currently using the method tfWidthController to check if the width is greater than the desired width and if so to decrease the font size in the css and reparse the css and have it autosize. But for some reason its not autosizing but the css is being manipulated. Do you see what im doing wrong? Thank you for taking the time to help me!

    package com.intentionally censored.view {
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.StyleSheet;
import com.intentionally censored.model.MatchupModel;
import com.ff0000.ads.utils.Trace;
import com.google.analytics.debug.Info;

public class MatchupView extends MovieClip {

    // on stage
    public var maxTextFieldWidth = 150;
    public var tf:TextField;
    private var baseFontSize = 10;
    public var $_tfCurrentWidth;

    public function tfWidthController():void {
        $_tfCurrentWidth = tf.textWidth;
        trace('textfields current width is ' + $_tfCurrentWidth);
        trace('textfields max width is ' + maxTextFieldWidth);
        while ($_tfCurrentWidth > maxTextFieldWidth) {
            trace ('$_tfCurrentWidth is '+$_tfCurrentWidth);
            trace ('maxTextFieldWidth is '+maxTextFieldWidth);
            baseFontSize-=1;
            applyStyles();
        }
    }

    private function get styles():StyleSheet {
        var _styles:StyleSheet = new StyleSheet();
        _styles.parseCSS("* {font-family:Playoff Bold Italic;font-style:boldItalic;}.em {font-size:"+(baseFontSize+2)+"px; }.redMicroTxt{font-size:"+baseFontSize+"pt;color:#c00000;}.medWhiteTxt{font-size:"+(baseFontSize+3)+"pt;color:#FFFFFF;}.redMediumTxt{font-size:"+(baseFontSize+6)+"pt;color:#c00000;}.whiteLargeTxt,.whiteMedTxt{font-size:"+(baseFontSize+6)+"pt;color:#FFFFFF;font-style:italic;}");   
        return _styles;
    }

    public function MatchupView() {
        tfWidthController();
        applyStyles();

    }

    protected function applyStyles():void {
        tf.styleSheet = styles;
        tf.autoSize = "center";
    }

    public function prepareFor( $_matchupModel:Object ):void {
        Trace.out( this, 'prepareFor()' );
        var _timeMessage:String = '';
        var _dateMessage:String = 'LIVE NOW'; // -------------- logic for 160 includes "\r"
        trace( $_matchupModel.gameStatus );
        if( $_matchupModel.gameStatus != 'Live Now' ) {             
            _timeMessage = $_matchupModel.timeMessage;
            _dateMessage = 'PM/ET';
        }


        tf.htmlText = '<span class="redMicroTxt">' + $_matchupModel.team1Rank + " "+'</span>'+
                        '<span class="whiteLargeTxt">' + $_matchupModel.team1 + '</span>'+
                        '<span class="medWhiteTxt"> vs </span>'+
                        '<span class="redMicroTxt">' + $_matchupModel.team2Rank + " "+'</span>'+
                        '<span class="whiteLargeTxt">' + $_matchupModel.team2 + '</span> '+
                        '<span class="redMediumTxt">' + _timeMessage +
                        '<span class="redMicroTxt">' + _dateMessage + '</span></span>';
    }

}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:06:16+00:00Added an answer on June 15, 2026 at 1:06 pm

    I figured it out – you need to change the htmlText every time you resize.

    while ($_tfCurrentWidth > maxTextFieldWidth) {
        trace ('$_tfCurrentWidth is '+$_tfCurrentWidth);
        trace ('maxTextFieldWidth is '+maxTextFieldWidth);
        var oldHtml:String = tf.htmlText;
        tf.htmlText = '';
        tf.htmlText = oldHtml;
        baseFontSize-=1;
        applyStyles();
    }
    

    I also did a working test for this and you can see it here: http://wonderfl.net/c/A310

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a reasonable size flat file database of text documents mostly saved in
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.