Rella
Rella

Reputation: 66985

How to send parameters to swf not using any html?

Is it possible to send params to swf using SWFLoader or something like it?

So.. I want to create swf loader (swf) which would be able to send some Application.application.parameters to swf swf I'm triing to load (which are usualy sent to an application from html.)

how to do such thing?

Upvotes: 3

Views: 1453

Answers (2)

a--m
a--m

Reputation: 4782

If you want to share variable between 2 swf then you can use SharedObject.

See for detailed help and a big example:

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/SharedObject.html#includeExamplesSummary

Or check this for a more comprehensive example: http://drawlogic.com/2008/01/10/howto-sharedobjects-for-local-storage-as3/

Some code to write a variable:

import flash.net.SharedObject;
var so:SharedObject = SharedObject.getLocal("userData");
so.data.username= "user1377";
so.data.pwdhash= "[hash] or pwd";
so.flush(); // writes changes to disk

code to read same variable:

import flash.net.SharedObject;
var so:SharedObject = SharedObject.getLocal("userData");
var username:String = so.data.username;
var pwdhash:String = so.data.pwdhash;

Just like a cookie ;)

Upvotes: 2

Theo
Theo

Reputation: 132972

You can add parameters in the URL, sort of like how you would send parameters to a script:

/path/to/the.swf?param=value

They will be available from ActionScript just like regular FlashVars, e.g. via Application.application.parameters["param"] in Flex, LoaderInfo(this.root.loaderInfo).parameters["param"] in AS3 or _root.param in AS2.

Upvotes: 5

Related Questions