Custom swc files

Hello all,

At the moment I´m working in a project where I build a swf via mxmlc including some compiled custom components via compc.

Just for testing, I created some classes and exported them as swc, and then include them in the movie.

Now it comes my question:

These swc components must include some assets (mainly a configuration.xml and some resources like images and sounds). I know I can include files when compiling the swc, but I dont know how to use them when actually I use the swc in the main movie…

Lets show you some things:

These are my compiled swc components:
compile_components.dashboard:
[exec] Loading configuration file /Developer/SDKs/Flex/frameworks/flex-config.xml
[exec] /bin/dashboard.swc (1399 bytes)

compile_components.avatar:
[exec] Loading configuration file /Developer/SDKs/Flex/frameworks/flex-config.xml
[exec] /bin/avatar.swc (1392 bytes)

Then I use them in my main movie:
var avatar:Avatar = new Avatar();
var dashboard:Dashboard = new Dashboard();
trace(avatar);
trace(dashboard);

which actually works:
[object Avatar]
[object Dashboard]

Now my wish would be to be able to set up the avatar via his own xml file. I would like to be able to use some assets included in the swc files, and configure them with certain values I will put in the configuration.xml (also included when compiling the swc and one xml per component).

The reason is simple: I want Avatar to be a fully configurable component, where i can set background images,positions, sounds, etc etc, and all that should be configurable only by changing some values in the xml file and include the assets. Then via ant, I compile the components and the main movie.

Maybe some guru out there made this before or knows how to make it.

Hope Its clear???

You could maybe [embed] the assets in the Avatar/Dashboard as classes before you compile them into the swc. Then you could access these items using avatar.thumbnailIcon which would return the embedded image, etc and so on.

That should work, can’t see why it wouldn’t. Just search for embedding assets if you get stuck.

edit: Hmm, it sounds like you’d want lots of assets though, so maybe embedding would be the wrong approach to keep file sizes down. Assuming your classes you are making the swc from are in a package folder create a folder within it called assets, then put the assets in there. I am not fully sure wether they will be included when you compile that swc though, you’d have to test it.

Hey Iamthejuggler!

Thanks for such a propmt reply!
The problem is that I dont want the designers to touch the classes. The thing would be to embed the assets only by editing a “manifest.xml” included with each component.

Its not really a big amount of assets, but I also need to change positioning, sizes, etc etc, and I dont see a better way to set all these parameters than by using a xml file.
Then the constructor of the class parses the manifest and “initialice” with the desided settings.

Still researching…

Thanks again!

Hello!!

I just made a small advance. Lets show you first:

This is the class for my component:


    public class Dashboard extends Sprite{
        
        // Dashboard configuration manifest ()
        [@Embed(source="manifest.xml", mimeType="application/octet-stream")] 
        private var manifest:Class; 
...
...


In this manifest I want to set up some properties for this component, as in size, positioning, etc.
Thus accessing the XML from inside the class:


        private function getXMLConfig() : XML{
               var ba:ByteArrayAsset = ByteArrayAsset( new manifest() );
               var xml:XML = new XML( ba.readUTFBytes( ba.length ) );
            trace(xml);
               return xml;    
        }

I have been reading that I could set a styles definition in a css file, where I could embed some assets if I compile the css into a swf file…but I could not make it to work.

Experience doing this someone?? My idea is to embed the assets like this:


Button {
    fontFamily: Tahoma;
    color: #000000;
    fontSize: 11;
    fontWeight: normal;
    text-roll-over-color: #000000; 
    upSkin: Embed(source="all_tip.png");
}

Then the designer could set up some style changes without having to touch any line in the code…which is my main goal.

TIA.