views:

216

answers:

2

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?

+4  A: 

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.

Theo
+2  A: 

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 ;)

dome