[swfmill] Accessing swfmlill library assets (png, mp3) from Flex/as3

Jonas Nyström jonasnys at gmail.com
Wed Nov 4 14:14:46 PST 2009


Hello!

I would like to replace my flex-compiler library creation with swfmill. My
problem is that I've not been able to
access any of my swfmill library assets. (In my current project i need png
images and mp3 soundfiles.)

This is how I create my Library.swf from a as3 class right now using flex
compiler:

package {
    import flash.display.Sprite;
    public class Library extends Sprite    {
            [Embed(source="assets/test.png")]
            public var TestPng:Class;
            [Embed(source="assets/test.mp3")]
            public var TestSound:Class;
    }
}

(This library creation is what I want to replace with a swfmill solution.)
The library is later used in my Flex app in the following way:

private var loader:Loader = new Loader();

private function onCreationComplete():void {
    this.loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
onComplete);
    this.loader.load(new URLRequest('assets/Library.swf'));
}

private function onComplete(e:Event):void {
    var resourceClass:Class =
loader.contentLoaderInfo.applicationDomain.getDefinition("Library") as
Class;
    var resources:Object = new resourceClass();

    // Png bitmap
    var symClass:Class=resources['TestPng'] as Class;
    var testBitmap:Bitmap = new symClass() as Bitmap;
    this.rawChildren.addChild(testBitmap);

    // Sound
    symClass = resources['TestSound'] as Class;
    var testSound:Sound = new symClass() as Sound;
    testSound.play(0);
}

Is it possible to create a swfmill Library.swf that has the same structure
and can be accessed the same way as my as3 library above? If not, could
anyone explain how to create and access images and mp3s in a corresponding
way?

Regards / Jonas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://osflash.org/pipermail/swfmill_osflash.org/attachments/20091104/7e6faa76/attachment.html>


More information about the swfmill mailing list