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 190277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:14:34+00:00 2026-05-11T16:14:34+00:00

The initial height of a text area is much larger than the content, I

  • 0

The initial height of a text area is much larger than the content, I cannot find a way of making it always the same height as the text content:

<mx:TextArea id="textarea" borderStyle="solid" width="100%" wordWrap="true" selectable="false" backgroundAlpha="0" focusAlpha="0" text="this is a little test" />

Gives a bordered box that is much taller than needed.

This also gives an unintential problem if you have links within the content in that a link ‘mouseover’ is triggered when nowhere near the link.

<mx:Script>
<![CDATA[
public function onInit():void
{
    var style:StyleSheet = new StyleSheet();

    var aLink:Object = new Object();
    aLink.color = "#0000FF";

    var aHover:Object = new Object();
    aHover.color = "#00FF00";
    aHover.textDecoration = "underline";

    style.setStyle( "a:hover", aHover );
    style.setStyle( "a:link", aLink );

    textarea.styleSheet = style;
}
]]>
</mx:Script>


<mx:TextArea id="textarea" width="100%" wordWrap="true" borderStyle="solid" selectable="false" backgroundAlpha="0" focusAlpha="0" >
    <mx:htmlText>
    <![CDATA[<a href='event:http://www.adobe.com'>Navigate to Adobe.com.</a> this is testing nothing at all really]]>
    </mx:htmlText>
</mx:TextArea>

The Text component doesnt suffer from this, but I cannot attach a stylesheet to a text component.

Hoping someone can help. Or is there some other component I can use where I can add a stylesheet to stylise anchor tags.

I found this overridable in the TextArea.as source and if I override it and remove the “2 x” multiplier it almost works but unfortunately it means that the content doesnt get bigger when it needs to and vertically scrolls instead, so its almost there:

override protected function measure():void
{
    super.measure();

    measuredMinWidth = DEFAULT_MEASURED_MIN_WIDTH;
    measuredWidth = DEFAULT_MEASURED_WIDTH;
    // TextArea is minimum of two lines of text
    measuredMinHeight = measuredHeight = 2 * DEFAULT_MEASURED_MIN_HEIGHT;
}
  • 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-05-11T16:14:34+00:00Added an answer on May 11, 2026 at 4:14 pm

    If you extend Text, you can add a getter/setter that allows you to set the styleSheet of the underlying UITextField object.

    package
    {
        import flash.events.Event;
        import flash.text.StyleSheet;
    
        import mx.controls.Text;
    
        import mx.core.mx_internal;
    
        use namespace mx_internal;
    
        public class StyledText extends Text
        {
            public function StyledText()
            {
                super();
            }
    
            private var _styleSheet:StyleSheet = null;
    
            [Bindable("stylesheetChanged")]
            public function get styleSheet():StyleSheet {
                return _styleSheet;
            }
    
            public function set styleSheet(value:StyleSheet):void {
                _styleSheet = value;
    
                if ( textField ) {
                    textField.styleSheet = _styleSheet;
                }
    
                dispatchEvent(new Event("stylesheetChanged"));
            }
    
            override protected function createChildren():void {
                super.createChildren();
    
                //textField is created in the createChildren 
                //method of the Label class
                if ( textField && styleSheet ) {
                    textField.styleSheet = _styleSheet;
                }
            }
    
        }
    }
    

    Then you can use the component like so:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ns1="*" preinitialize="onInit()">
        <mx:Script>
        <![CDATA[
        public function onInit():void
        {
            var style:StyleSheet = new StyleSheet();
    
            var aLink:Object = new Object();
            aLink.color = "#0000FF";
    
            var aHover:Object = new Object();
            aHover.color = "#00FF00";
            aHover.textDecoration = "underline";
    
            style.setStyle( "a:hover", aHover );
            style.setStyle( "a:link", aLink );
    
            text.styleSheet = style;
        }
        ]]>
        </mx:Script>
    
    
        <ns1:StyledText id="text" x="0" y="79">
            <ns1:htmlText>
            <![CDATA[<a href='event:http://www.adobe.com'>Navigate to Adobe.com.</a> this is testing nothing at all really]]>
            </ns1:htmlText>
        </ns1:StyledText>
    
    </mx:Application>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Textblock which has an initial amount of text and height of
I use this meta-tag <meta name=viewport content=width=device-width, initial-scale=1.0, user-scalable=no> And I have a text
My initial task was to find a segmenter for Windows that will split a
is there any initial content of ~/.subversion/servers config file? I tried to look in
I have a JavaFX applet with the stage's initial height and width defined as
NSString *HTML = [NSString stringWithFormat:@<html> \n <head> \n <meta name=\viewport\ content=\width=device-width; initial-scale=1.0; maximum-scale=1.0;\> <div
Initial Question Yesterday i read about ECMAScript 5 Object.create() And I wanted to start
Initial tests indicate that GDI+ (writing in VB.NET) is not fast enough for my
My initial question was here and was related to the postgres backend. Postgres subquery,
I am in initial stage of MDM Server implementation, I know that when ever

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.