What is the best way to share assets - icons / images - across multiple Flex applications?

I am creating a new - "lite" version of the Flex application that I created some time ago. I have ported many of the classes and components to a Flex library project that compiles a SWC file. Since both are Cairngorm applications, I cannot completely eradicate duplicate code, but it is logical that I should be able to share assets - for example, icons (PNG files). What is the best way to do this? I tried to include them in the SWC, but I cannot figure out how to access them in the application. If you can help me figure this out, then my question will be given. Any thoughts?

Here is an example of how I am currently embedding icons / images in a Flex application:

<mx:Script>
    <![CDATA[
        [Bindable]
        [Embed(source="assets/icons/cancelIcon.png")]
        private var cancelIcon:Class;

        [Bindable]
        [Embed(source="assets/icons/saveIcon.png")]
        private var saveIcon:Class;
    ]]>
</mx:Script>

Thanks.

+3
3

0) -, - :

// Actionscript instead of MXML:
public class ResourceClasses
{
        Bindable]
        [Embed(source="assets/icons/cancelIcon.png")]
        public static var CancelIconClass:Class;

        // make your variable public and static without public no one 
        // outside the class can access AND bindable won't matter
}

---- , . ---- ,

1) /swc

---- /intellisense Flex Builder/eclipse

2) - - :

var image:Image = new Image();
image.source = ResourceClasses.CancelIconClass;

// more image property setting... 

someCanvas.addChild(image);

3) - ..

*** DO . , .. - , , ..

+4

, @Gabriel, :

package
{
    [Bindable]
    public class ResourceClasses
    {
        [Embed(source="assets/icons/cross.png")]
        public static var CancelIconClass:Class;
    }
}

:

<?xml version="1.0" encoding="utf-8"?>
<mx:Box xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Button label="Cancel Changes" icon="{ResourceClasses.CancelIconClass}" />
</mx:Box>

!

0

Source: https://habr.com/ru/post/1710091/


All Articles