actionscript-3loaderflashvars

How can I pass FlashVars to the swf loaded by Loader.loadBytes?


When I load it by Loader.load I can pass them via URLRequest. But I don't see any opportunity in case of Loader.loadBytes. This question is similar to Passing flashvars-style parameters to a loaded SWF.


Solution

  • The answer is in API documentation. I've been hinted at another site.

    You should use parameters property of LoaderContext object which you pass to the Loader.loadBytes method. But it works only for the AS3 swfs. It seems to be imporsible for the AS1/2 swfs.

    var swf:ByteArray = getSWF();//swf bytes from nowhere
    var loader:Loader = new Loader()
    var loaderContext:LoaderContext = new LoaderContext();
    loaderContext.parameters = {a: "1", b: "2"};
    loader.loadBytes(swf, loaderContext);
    

    I think it's right answer for now.