Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Assets to a Flex Library?

Tags:

apache-flex

I'm trying to add assets into a flex library .swc file with no success.

The assets folder in the library project contains a gif file. The project also contains a Spark Group componnent that displays the image.

When i try to use this componnent in a different project the image is not visible. If i copy the assets folder from the library project to the main project the image is visible.

I added the assets folder in the Flex Library Build Path

Why aren't the assets contained by the swc?

Thank you!

Attached screenshots: enter image description hereenter image description here

like image 665
Dan Dinu Avatar asked Nov 04 '22 03:11

Dan Dinu


1 Answers

Create class in library project

package resources
{
    public final class IconResource
    {
        //list embedded items - you can embed any files, mp3 etc

        [Embed (source="../assets/facebook.gif" )]
        public static const icon_facebook:Class;    

        public function IconResource()
        {}
    }
}

Using in production projects:

import resources.IconResource;

var img:Image = new Image();
img.source = IconResource.icon_facebook;

or

<fx:Script>
  <![CDATA[
    import resources.IconResource;
  ]]>
</fx:Script>

<s:Image source="{IconResource.icon_facebook}"/>
like image 172
Y Borys Avatar answered Nov 06 '22 14:11

Y Borys