Copy link to clipboard
Copied
hey guys... so im trying to load a swf using the SWFLoader, and i need to some how send a variable to that swf, and in that swf i need to capture that variable if that makes any sence...
the swf is made in flash, and a function init is called everytime the swf loads...
in that init function in the flash actionscript i need to capture the variable i send from flash builder....
so far i have the following code...
in this code i have no idea on how to send variables to my swf
var swfLdr:SWFLoader = new SWFLoader();
swfLdr.horizontalCenter = 0;
swfLdr.verticalCenter = 0;
swfLdr.source = "http://test-broadcast.apxinsider.com/Content/swf/office_weekly_UF.swf";
swfLdr.addEventListener(Event.INIT, swfLoaded);
swfLdr.load();
now i was htining i could do somehting like office_weekly_UF.swf?id=1304 or somehting... but if i do that, how do i capture this in my swf???
any thing would help! thank you so much!
Copy link to clipboard
Copied
any takers??
Copy link to clipboard
Copied
Hi,
I'll put up what i think is the answer. Do tell me if this is what you are looking for. When I created the swf in Flash Pro.This is the code I used
var keyStr:String;
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
for (keyStr in paramObj) {
urlText.text = String(paramObj[keyStr]);
}
urlText is a text box whose content text is passed as a URL parameter. The parameters can be retrieved from paramObj. Is that what you meant by capturing the variables?
Then on the flex side, this is the code i used to display from SWFloader
import mx.controls.SWFLoader;
private var swfLdr:SWFLoader;
private function startSWF():void
{
swfLdr = new SWFLoader();
swfLdr.horizontalCenter = 0;
swfLdr.verticalCenter = 0;
swfLdr.source = "MySWF.swf?urlText=verbose";
addElement(swfLdr);
}
I hope this helps.
Nishad
Copy link to clipboard
Copied
hi Nishad, well i looked a lot into this, and i found out that after loading the swf i am able to access public function and variables after the swf has loaded, therefore i just modified all the swfs to fit my need, where i just ended up doing somehting like the following
swfLdr = new SWFLoader();
swfLdr.horizontalCenter = 0;
swfLdr.verticalCenter = 0;
swfLdr.source = "/content/swf/" + tempFileName;
swfLdr.addEventListener(Event.COMPLETE, swfLoaded);
swfLdr.load();
}
private function swfLoaded(event:Event):void{
swfLdr.removeEventListener(Event.COMPLETE, swfLoaded);
childSwf = new MovieClip();
childSwf = event.target.content;
childSwf.init(1);}
Copy link to clipboard
Copied
Oh.. Nice. This is good info. If you've resolved any of the other issues like the sandbox issue, do post your findings.
Nishad
Copy link to clipboard
Copied
i havent read thru the sandbox article yet, but i just ended up moving my release build swf to the server to get around that problem....