Reputation: 66985
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
Reputation: 4782
If you want to share variable between 2 swf then you can use SharedObject.
See for detailed help and a big example:
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
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