Embedding images in buttons in Flex

January 20th, 2010  Posted at   Adobe Flex, Uncategorized
arrow   |   No Commentsarrow

Forgive me if this is trivial and beginner (because it is :) ).

Here are two ways to get an image into a button.

First Method, using assets added to the project:
1. Open project properties, go to Flex Build Path, Source path tab, and click Add Folder…
2. Add the folder of images to your project
3. Reference an image in a button like this:
<mx:Button label=”Ok”
  icon=”@Embed(source=’accept.png’)” />
(A ton of great icons at Famfam)

Second Method, using absolute referenced assets:
1. Reference an image in a button like this:
<mx:Button label=”Ok”
  icon=”@Embed(source=’c:/assets/icons/famfam/accept.png’)” />
(Note the forward slashes)

Leave a Reply

You must be logged in to post a comment.