views:

2922

answers:

4

I have some HTML that is generated via a Rich Text Editor outside of my Flex application but would like to display it inside Flex.

The HTML is simple HTML tags, things like styles, anchors, and possibly image tags, is there a control that would let me render this HTML in flex or am I going to have to roll up my sleeves and roll my own?

Any ideas appreciated...Thanks.

+3  A: 

If the HTML is really simple, you can display it in a normal label or textarea component, If it is more complex, I'll quote what I answered in this question. The discussion there also has a little more info.

If it is complex HTML and Javascript, one possible way is HTMLComponent, a method that uses an iframe over your flash to make it appear like the HTML is in your app. There are a few downsides to this method however - most of them described in detail at Deitte.com.

If this can move offline, you could use Air (it has an mx:HTML component built in). Deitte.com has a detail of this technique as well.

81bronco
A: 

@81Bronco

The main thing I need is to display images tags...I don't think a label or textarea area can do this...

mmattax
+1  A: 

Check out the documentation on mx.controls.Label and flash.text.TextField (which is what displays the text in a Text or Label control in Flex). The TextField documentation states that

The <img> tag lets you embed external image files (JPEG, GIF, PNG), SWF files, and movie clips inside text fields. Text automatically flows around images you embed in text fields. To use this tag, you must set the text field to be multiline and to wrap text.

Which means that you can display an image in a Text component in Flex by setting its htmlText property to some HTML which contains an <img> tag. You can't use Label, because it is not multiline.

I've noticed that text fields have trouble with properly measuring their heights if the images displayed in them are left or right aligned with text flowing around them (e.g. align="left"). You may have to add some extra spacing below to counter that if you plan to use aligned images.

Theo
A: 

@mmattax

Indeed you can display images in a TextArea component. The approach is not entirely without problems though...

Niko Nyman