ssURLLoader Overview

ssURLLoader is an AS3-only class that loads files from the internal layout of a SWF Studio-built application into Flash directly from memory.

ssURLLoader replaces ssSecure functionality for loading files from the layout. The big difference is that ssURLLoader does so without an HTTP server, so firewalls won't be triggered. Files are loaded directly from the EXE into Flash without first being extracted and with no way of anyone getting the file from outside your application.

ssURLLoader mimics the functionality of flash.net.URLLoader with the following exceptions:

ssURLLoader is NOT a replacement for URLLoader.

The idea is that you can interchange the two classes as required.

For more information on the ActionScript 3 URLLoader class check out the Adobe LiveDocs ActionScript 3 URLLoader Reference


Examples:

The following example loads a SWF file from the layout into a Flash Loader object. If you run the example as a SWF outside of SWF Studio the loadme.swf file is expected to be in the same directory, inside of SWF Studio the loadme.swf file is expected to be in the root of the layout.

package
{
    import flash.display.Sprite;
    import flash.net.URLRequest;
    import flash.display.Loader;
    import flash.events.Event;
    import flash.net.URLLoaderDataFormat;
    import flash.net.URLLoader;

    public class ssURLLoaderTest extends Sprite
    {
        public var req:URLRequest;
        public var ldr:Loader;
        public var uldr:*;
    
        public function ssURLLoaderTest()
        {
            addEventListener(Event.ADDED_TO_STAGE, onAdded, false, 0, true);
        }
    
        public function onAdded(e:Event):void
        {
            removeEventListener(e.type, arguments.callee);

            ldr = new Loader();
            req = new URLRequest();
    
            if (ssCore.isEXE)
                uldr = new ssURLLoader();
            else
                uldr = new URLLoader();
        
            uldr.addEventListener(Event.COMPLETE, onComplete);
            uldr.addEventListener(ProgressEvent.PROGRESS, onProgress);
            uldr.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
    
            req.url = 'loadme.swf';

            if (ssCore.isEXE)
                uldr.bufferSize = '8192';

            uldr.dataFormat = URLLoaderDataFormat.BINARY;
            uldr.load(req);
        }
    
        public function onProgress(e:ProgressEvent):void
        {
            ssDebug.trace('onProgress: '+e.bytesLoaded+' of '+e.bytesTotal);
        }
    
        public function onIOError(e:IOErrorEvent):void
        {
            ssDebug.trace('onIOError: '+e.text);
        }
    
        public function onComplete(e:Event):void
        {
            ssDebug.trace('onComplete');
            ldr.loadBytes(uldr.data);
            addChild(ldr);
        }
    }
}