This is my ActionScript 3.0 code:
var ldr: Loader = new Loader();
var upldata = "testabc=test1";
var v: URLVariables = new URLVariables(upldata);
var r:URLRequest = new URLRequest();
r.url = "as2.swf";
r.method = URLRequestMethod.POST;
r.data = v;
trace("loading", r.url);
ldr.addEventListener(Event.COMPLETE, fnccomp);
ldr.addEventListener(IOErrorEvent.IO_ERROR, fncerr);
function fnccomp(ev: Event) {
trace("complete");
}
function fncerr(ev: IOErrorEvent) {
trace("error", ev);
}
ldr.load(r);
addChild(ldr);
In the as2.swf file, there are two trace commands (using ActionScript 2.0 for this Flash file):
trace(“as2.swf " + _root.testabc);
trace(”_level0.testabc: " + _level0.testabc);
This outputs:
loading as2.swf
as2.swf undefined
_level0.testabc: undefined
Changing this line:
r.method = URLRequestMethod.POST;
to
r.method = URLRequestMethod.GET;
results in:
loading as2.swf
Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
So, how to do this correctly so that I can access the “testabc=test1” variable/value from the as2.swf file?