Tuesday, December 1, 2009

Passing values to Flash using swfobject and capturing in Flash using AS3

Just like flashvars you can pass values to Flash even if you are using swfobject to display your flash. Below is the code to do that -

var so = new SWFObject("flash/465x535.swf", f_size, "385", "535", "9", "");
so.addVariable("file_path", "filename.jpg");

file_path is the variable which will be passed to Flash. Now to capture the value in Flash using AS3 the code will be as follows -

var filepath = root.loaderInfo.parameters.file_path;