I’ve got a SWF that collects feedback from users on a website. The questions asked are pulled in as XML, using a URL supplied via flashvars embedded in the page. Unfortunately, this appears to have broken in the latest version of my SWF.
Here is how I am embedding the object:
<script src="swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF("http://localhost/mysite/q.swf", "flashcontent", "900", "360", "9.0.0", "http://localhost/mysite/expressInstall.swf", { loadurl: escape("http://localhost/mysite/q.php?q=13") }, {}, {});
</script>
</head>
<body>
<div id="flashcontent">
</div>
</body>
I’m attempting to pull out the loadurl flashvar like this:
this.loaderInfo.addEventListener(Event.COMPLETE, function(e:Event) {
init();
});
function init()
{
*snip*
loadurl = unescape((loaderInfo.parameters.loadurl));
}
Using ExternalInterface.call() to call console.log in the browser outputs null, yet in a previous version (where this code has remained unchanged) it works and outputs the URL as I would expect. I can switch between them see it working on the earlier, then update to the newer one and it outputs null again.
The only change in this newer version of the asset is that I added a symbol and a bit of code to add that to the stage after the XML has been loaded – but that did not in any way change the code getting the URL from the page’s HTML.
I’m using Flash CS5 and it is an ActionScript 3.0 project.
Can anyone suggest where I am going wrong? I’ve spent ages pulling my hair out over this one, so any help would be greatly appreciated. I did read somewhere that this could be done via ExternalInterface – would it be more appropriate for a scenario such as this? Is it a viable alternative if for some reason I can’t get this to work properly?
Thanks!
The workaround here was to eventually use
ExternalInterface.call. Unfortunately I could not work out why the flashvars where not being passed to the SWF correctly, despite much messing about with HTML, SWFObject etc.