[AS3] - Send a string value to an external SWF while loading it - possible or not?

Hey DaniMun I found your post because I was looking for a similar solution… to the other devs, yes it is easier to just pass it in the URL, but one reason to pass a SWF could be to attach analytics inside of it :slight_smile:

Anyways Dani I posted my question here and it got answered with great working code:

DaniMun said

Hey guys, was wondering if that’s doable - basically I have main.SWF into which I’m loading external.SWF and would need to pass the path to an XML file to external.SWF, so that external.SWF knows which XML to use.

/** code in main.SWF **/

import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;

var ldr:Loader = new Loader();
var externalFullPath:String = "external.swf?xmlFile=different.xml";//here I'm specifying the path to the SWF file along with the XML that it should use
var rq:URLRequest = new URLRequest(externalFullPath);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
ldr.load(rq);

function done(e:Event):void
{
	addChild(e.target.content);
}

Would that be achievable?

Thanks! :slight_smile: