Search code examples
apache-flexruntimestylesheet

Multi line text in Flex doesnt recalculate when runtime css is changed


For loading time considerations I am using a runtime css file in my Flex Application.

I am having a problem with a multi line text control :

<mx:Text id="txtDescription" selectable="false"
styleName="imageRolloverButtonTextDark" width="100%" textAlign="center"
text="{_rolloverText}"/>

When my CSS stylesheet has loaded the text style correctly changes, but the height is not recalculated. It appears to be just a single line field.

FYI: The control is not actually visible, and triggered by a rollover. So I dont really care if the stylesheet hasnt loaded and they get standard system text. I jsut want it to be the correct height when it has been loaded.


Solution

  • For any one else who has this problem, The solution I found was to create a custom component extending the mx.controls.Text

    and then override the styleChange() Method, and explicitly call the invalidateDisplayList() method for the text field once the style has been applied.

    It should be called automatically when the styleis changed but no...for some reason in flex 3.5 it is not.

    public class TextObject extends Text { //... override public function styleChanged(styleProp:String):void { invalidateDisplayList(); } }

    Hope that save some one all the time I lost on it.