I think the easiest way to get the URL of your redirected swf and its parameters is to use another swf as the loader for your current one, where you can get the URL and parameters passed to your redirected swf, and then you can send it to JavaScript via ExternalInterface
To do this, take a look at this example:
ActionScript:
// url : the url of the current swf // this url is passed by flash vars in the html page // default value : http://www.example.com/redirect var swf_url:String = this.loaderInfo.parameters.url || 'http://www.example.com/redirect', // fn : the name of the js function which will get the url and the message param // this name is passed by flash vars in the html page // default value : console.log js_function:String = this.loaderInfo.parameters.fn || 'console.log', message:String = 'no message'; var url_request:URLRequest = new URLRequest(swf_url); var swf_loader:Loader = new Loader(); swf_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, on_content_load); swf_loader.load(url_request); function on_content_load(e:Event): void { var loader_info:LoaderInfo = LoaderInfo(e.currentTarget); // get the message param or use the default message message = loader_info.parameters.message || message; // if ExternalInterface is available, send data to js if(ExternalInterface.available) { // send the swf url and the message param to the js function ExternalInterface.call(js_function, { url: loader_info.url, message: message }); } // show the redirected loaded swf addChild(swf_loader); }
HTML side:
In this example, suppose we have a .htaccess file, for example:
.htaccess:
Redirect /redirect /new.swf?message=a%20message%20here
JavaScript:
function get_data_from_flash(data) { console.log('url : ' + data.url);
HTML:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="400"> <param name="movie" value="loader.swf" /> <param name="flashvars" value="url=http://www.example.com/redirect&fn=get_data_from_flash" /> <object type="application/x-shockwave-flash" data="loader.swf" width="550" height="400"> <param name="flashvars" value="url=http://www.example.com/redirect&fn=get_data_from_flash" /> </object> </object>
What all!
If you want to know more about how to use ExternalInterface , you can look here .
Hope this helps.
source share