0 Replies Latest reply on Sep 6, 2012 4:08 AM by ChristianKiefer

    Loosing html-Tag-coloring in TextArea - Flex mobile

    ChristianKiefer Level 1

      http://help.adobe.com/en_US/flex/mobileapps/WS19f279b149e7481c-3c2dbaa612bb06a5ea2-8000.ht ml

       

      ...this is working fine - also with coloring (<font color="#FF0000"> ...)but if you remove the TextArea from the stage and readd it all colors are gone...

       

      Can somebody tell me why?

       

      I found that the color-tags are removed from flash/flex somehow...

       

      ... the following hacky class fixes this for me... but has anyone an idea how to solve this in a better way????

       

       

      /**

      */

      package

      {

                import flash.events.Event;

       

       

                import spark.components.TextArea;

                import spark.components.supportClasses.StyleableTextField;

                import spark.skins.mobile.TextAreaSkin;

       

       

                public class TextAreaFix extends TextArea

                {

       

       

                          private var htmlTextChanged:Boolean;

                          private var _htmlText:String;

       

       

                          override public function set text(value:String):void

                          {

                                    super.text = value;

                          }

       

       

                          public function set htmlText(value:String):void

                          {

                                    _htmlText = value;

                                    htmlTextChanged = true;

                                    invalidateProperties();

                          }

       

       

                          public function get htmlText():String

                          {

                                    return _htmlText;

                          }

       

       

                          public function TextAreaFix()

                          {

                                    super();

                                    setStyle("skinClass", Class(TextAreaSkin));

                                    addEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);

                          }

       

       

                          private function handleAddedToStage(event:Event):void

                          {

                                    callLater(resetHtmlText);

                          }

       

       

                          private function resetHtmlText():void

                          {

                                    htmlTextChanged = true;

                                    invalidateProperties();

                          }

       

       

                          override protected function commitProperties():void

                          {

                                    super.commitProperties();

                                    if(htmlTextChanged && textDisplay)

                                    {

                                              StyleableTextField(textDisplay).htmlText = htmlText;

                                              StyleableTextField(textDisplay).commitStyles();

                                              htmlTextChanged = false;

                                              invalidateDisplayList();

                                    }

                          }

       

       

                          override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void

                          {

                                    super.updateDisplayList(unscaledWidth, unscaledHeight);

                          }

       

       

                }

      }