user1826684
user1826684

Reputation: 128

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.

Upvotes: 1

Views: 1327

Answers (2)

Alberto
Alberto

Reputation: 131

Great! runs for me only if parameters are strings:

loaderContext.parameters = {"a": "1", "b": "2"};

Upvotes: 0

user1826684
user1826684

Reputation: 128

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.

Upvotes: 2

Related Questions