views:

32

answers:

2

Here there's a brief explanation of how we can "simulate" the RSL system used in Flex with pure AS3: http://stackoverflow.com/questions/1201659/loading-an-rsl-without-using-flex

But what about signed RSLs? can we use that technique to load SWZ files too? will them be cached by the player? how can we "reuse" a SWZ cached by the player in a pure AS3 project?

Thanks! Enrique.

+2  A: 

Signed SWC (ie SWZ) are loaded into the flash player cache rather than the browser cache. Therefore only uber trusted code is allowed which at the moment comes from Adobe only.

For preloading? Only way i know is not really a way, but say you have an info page or login page before your Flex app, load the RSLs when the user is maybe reading something by including a lightweight SWF that uses the same RSLs as your main app. Its a cheat, but seen it used when bandwidth is a minimum and want to get bang for buck when an app first loads.

Preloading any other way outside the player I could see security concerns with.

David Collie
I'm not using Flex, is a pure AS3 project, and I want to use SWZ signed by Adobe, but Without Flex, because I want to be able to use the Flash Player cache. Maybe I did't explain it very well, sorry.
Enrique
Substitue Flex for ActionScript project, it doesn't matter. I will assume you are using Flash Builder, create a project, add the necessary SWZ to your Library path.
David Collie
http://www.mail-archive.com/[email protected]/msg126447.html
David Collie
Are you sure? this is from Adobe:"You cannot use RSLs in ActionScript-only projects if the base class is Sprite or MovieClip. RSLs require that the application’s base class, such as Application or SimpleApplication, understand RSL loading."And I don't want to use the Flex Framework (just the TLF).
Enrique
Also, I don't want a movie with 2 frames and the preloader in the first frame like Flex does (and this is neccesary for RSL). I have my own preloader in a separated SWF.
Enrique
A: 

OK, This is the solution (not tested yet but I'm pretty sure it works)

Example from the Adobe's AS3 Reference:

//URLRequest, digest property:

var myURLReq:URLRequest = new URLRequest();
myURLReq.url = "http://yourdomain/users/jdoe/test01/_rsc/Automated/AssetCaching_rsc/test01/rsl.swz";
myURLReq.digest = "3B0AA28C7A990385E044D80F5637FB036317BB41E044D80F5637FB036317BB41";
var myURLLoader:URLLoader = new URLLoader();
myURLLoader.dataFormat = URLLoaderDataFormat.BINARY;
myURLLoader.addEventListener("complete", onC);

myURLLoad.load(myURLReq);

function onC(e) {
    var someLoader:Loader = new Loader();
    addChild(someLoader);
    someLoader.loadBytes((ByteArray)(myURLLoad.data)); 
}

So, we can load a signed RSL (.SWZ) like any other SWF, BUT! we must use URLLoader, not Loader, and provide the digest property. Then we use Loader to load the byteArray from URLLoader. The signed SWZ is checked internally by the Player, and if it detects is signed by adobe, then it will be cached by the Player, we don't need to do anything. I think Flash Player checks automatically, and before loading any SWZ, if that SWZ is already cached by the player.

That's all I think.

if you want to see more details, check my reply in FlexCoders:

http://tech.groups.yahoo.com/group/flexcoders/message/159010

Enrique