7 Replies Latest reply on Oct 7, 2009 3:29 PM by Peter deHaan

    HTML Text in Spark TextArea

    DilipShah Level 1

      Halo TextArea's htmlText property is not available in Spark TextArea. How does one go about displaying dynamic HTML text (via ActionScript) in a Spark TextArea?


      It looks like I need to use 'content' property but Flex 4 Language Reference has no documentation on that property.

        • 1. Re: HTML Text in Spark TextArea
          Peter deHaan Level 4

          @Dilip Shah,


          There are a few different ways of setting rich formatted text in a RichText/RichEditableText/TextArea control in Flex 4:


          http://blog.flexexamples.com/2009/08/11/setting-text-in-a-spark-richtext-control-in-flex-4 /




          • 2. Re: HTML Text in Spark TextArea
            DilipShah Level 1
            Thanks Peter!
            I was using 4.0.0 sdk, which doesn't have classes  such as TextFlowUtil, etc. So I downloaded a nightly build ( and now  I have all the latest stuff but it breaks what used to work with 4.0.0! This sdk  version is giving bunch of internal build errors and when I switch to Error Log  view, I see dozens of "Uncaught exception in compiler"! I'm using Flash Builder  Plug-in and I have Eclipse Galileo.
            The latest skd also throws errors on classes that  used to work with 4.0.0, such as
            s:SimpleText with error:  Could not resolve <s:SimpleText> to a component  implementation.
            Is there a stable build that I can download and use  that has classes I need to add HTML text in a TextArea?
            • 3. Re: HTML Text in Spark TextArea
              Peter deHaan Level 4

              @Dilip Shah,


              In the latest nightly builds of the Flex 4 SDK, the <s:SimpleText/> class has been renamed to <s:Label/>. For more information, see http://blogs.adobe.com/pdehaan/2009/09/spark_primitive_text_changes_f.html and http://opensource.adobe.com/wiki/display/flexsdk/Spark+Text+Primitives+Decision.


              I always suggest downloading and using the latest Flex 4 nightly SDK available as it always represents the latest code base.



              • 4. Re: HTML Text in Spark TextArea
                Peter deHaan Level 4

                In fact, here's a simple example of converting a simple HTML formatted string to a TextFlow using the TextConverter class and displaying the markup in a RichText control:

                <?xml version="1.0" encoding="utf-8"?>
                <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                            import flashx.textLayout.conversion.TextConverter;
                            private const htmlStr:String = "<p>The quick brown <b>fox</b> jumps over the lazy <i>dog</i>.</p>";
                    <s:RichText id="richTxt" x="20" y="20" width="100">
                        <s:textFlow>{TextConverter.importToFlow(htmlStr, TextConverter.HTML_FORMAT)}</s:textFlow>




                • 5. Re: HTML Text in Spark TextArea
                  Peter deHaan Level 4

                  Sorry, one final point... If you're working in Flex 4/Flash Builder 4, a better forum is the Gumbo forum at http://forums.adobe.com/community/labs/gumbo?view=discussions&start=0 which is a bit more closely monitored by both the Flex SDK and Flash Builder teams.


                  Good luck, and happy Flexing!


                  • 6. Re: HTML Text in Spark TextArea
                    DilipShah Level 1

                    I posted this issue on "Flash Builder and Flex SDK" forum but haven't received any feedback / resolution yet. Till this issue is resolved, I'm staying away from nightly builds.


                    However, outside of Flash Builder issues, I tried compiling my code using the at command line and received a bunch of errors where the 4.0.0 worked just fine.


                    A few examples:

                    1. s:List used to have 'selectionChanged' event that needs to be now replaced with 'change' event


                    2. I use the following construct for the application's skin:

                        <s:Rect id="backgroundRect" left="0" right="0" top="0" bottom="0"  >
                                <s:SolidColor color="{hostComponent.backgroundColor as uint}" />

                    Now, the compiler is compaining that backgroundColoris an undefined Application property.


                    and so on... there are many such compiler errors!


                    I understand that the product is in beta and there are going to be changes along the way. But, is there one place on the web that one can monitor for such changes?



                    • 7. Re: HTML Text in Spark TextArea
                      Peter deHaan Level 4

                      @Dilip Shah,


                      Re: #1) Correct. I believe the s:List now has changing and change events instead of selectionChanged.


                      Re: #2) I believe the Application.backgroundColor was changed from a property to a style.


                      As for where you can monitor the changes... We use SVN, so you could subscribe to the checkin notes. I subscribe to notifications from the following forum: http://forums.adobe.com/community/opensource/flexsdk/commits