2 Replies Latest reply on May 27, 2009 5:03 AM by Adrian Webb

    Question about TextFormat an TextField classes

    Adrian Webb

      Hi,

       

      I have noticed that the TextField class accepts an <img> tag.  You also format text fields with TextFormats.  But TextFormats do not support image tags.  They support anchor tags, but not image tags.

       

      I am trying to build a replacement for the RichTextEditor component that ships with the Flex SDKs, for a project I am working on, that has image support.  It is still based on the TextField so it has the characteristics of the RichTextEditor to some extent.  What I wanted to do was extend the TextFormat class and give it image related fields, that way I could reuse the formatting logic of the textfield.  But since TextFormat is a native flash class I can not find out how to do this.

       

      My assumptions have been that the TextFormat class takes the fields given in a range of text and generates the appropriate markup between textformat tags in a given order; texformat, p, font, a, b, i, u, etc...  But I have been experiementing with extending this class and I can not tell how the html gets rendered with it.  If I call the toString() method (which is documented to exist) the app gives me a [ error 1061: Call to a possibly undefined method toString through a reference with static type flash.text:TextFormat ] so I assume that this is not the way that the html is generated and it doesn't seem to have any other methods.

       

      So basically my question is this; is it possible to extend the TextFormat class the way I mentioned to get image support or do I have to write my own formatting mechanism and abandon the built in TextFormat mechanism?  This is probably a question for an Adobe person, considering that the flash classes are not open source, which I desperately wish was not the case :-(   So how does this formatting system really work?

       

      Thanks for any help you can provide with this problem.

       

      Thanks,

      Adrian

        • 1. Re: Question about TextFormat an TextField classes
          GordonSmith Level 4

          TextField and TextFormat are native Player classes written in C++, not ActionScript. Adobe does not make this C++ code available. You can subclass both of them in ActionScript, and you should be able to make YourTextField use YourTextFormat. I'm not exactly clear on what you want to do with images, so I can't offer specific suggestions.

           

          However, please be aware that these classes are being obsoleted in favor of the new Flash Text Engine ("FTE") classes in Player 10's flash.text.engine package. And an AS library called the Text Layout Framework ("TLF") builds on top of FTE to add capabilities that surpass what TextField can do, including support for inline images. Finally, Flex 4 components are built on top of FTE and TLF. (For an example of what FTE and TLF can do, take a look at the new Times Reader AIR app for the New York Times.)

           

          Since FTE, TLF, and Flex 4 are the future of text in the Flash Player, you should think about whether you want to build an editor on them instead of on TextField, which is not being considered for any future improvements.

           

          Gordon Smith

          Adobe Flex SDK Team

          • 2. Re: Question about TextFormat an TextField classes
            Adrian Webb Level 1

            Thanks for the information.  I will definitely look into that.  One question, I chose to go with Flex 3 because Flex 4 does not have an official release yet.  I think I read that the time table puts the release in the fall of this year some time.  I am very excited about what I have seen in Flex 4 and can't wait to use it in my development.  Would you consider the current build of Gumbo (which from my understanding, is the only SDK that supports Flash 10 player) ready to be used in a production environment?  This is important because I need to build out this app before the fall of this year.

             

            On a side note;  I am really glad to see the separation of skinning and component logic in Gumbo.  In Flex 3 I resort to using the code-behind design pattern for visual component development.  Keep up the good work!