The other day, someone asked me how they could re-use the code sample from Igor Costa’s post about getting the Rich Text Editor to output XHTML. Whenever you want to add functionality to an existing control, you just need to extend it. Here’s how:
Here’s the top bit of code from my XHtmlEditor.as file:
public class XHtmlEditor extends mx.controls.RichTextEditor
public function XHtmlEditor()
The actual code where I’m telling the compiler that this object extends RichTextEditor is line 5. You can then see that in the constructor method, I call super() on line 9. The super() method just calls the original constructor of the RichTextEditor object.
From here, we define a getter and setter method for a property called xhtml. The xhtml property doesn’t actually store any value in our object, we just use it as an interface to the convertToXHtml() and convertFromXHtml() methods from Igor’s blog post.