I am currently working on a Flash project. Because it has a lot of GUI stuff and it is always a lot of code to make some nice GUI components in pure ActionScript 3 I decided to give Flex a change. Surprisingly I really like it. It’s nice and a little bit sick (for a framework a lot of magic happens during compilation). Like for ActionScript 3 Adobe again did a really good job on writing a nice documentation.

But not everything works flawless. Here is a thing struggled with:

Embedding an image is quite easy (the image will be compiled into the final swf file):

  1. <mx:Image source="@Embed(source=’image.jpg’)"/>

Using HTML to format text shouldn’t be a problem for anyone.

  1. <mx:Text width="100%">
  2.   <mx:htmlText>
  3.     <![CDATA[<p><img src='url'/>some text</p>]]>
  4.   </mx:htmlText>
  5. </mx:Text>

This will show the image from the given URL and “some text”. The Image is going to be loaded when displayed, it is not embedded into the swf file.

How to use a embedded image in a HTML text element? continue reading…