Download AS2 SWF to AS3 SWF and skip vars in URL

I have an AS3 SWF into which I will load other SWFs. These child SWF files accept one parameter in the URL. I cannot get it to work when loading the AS2 child, and it should be able to handle both.

that's why I am

var request:URLRequest = new URLRequest();
var loader:URLLoader = new URLLoader();

request.url = "http://domain/as2.swf?param=foo";
loader.load(request);
// etc on to the eventListeners, addChild, etc

When SW2 as2 loads, it cannot see the parameter that I passed to it. He is looking for _root.param. Am I doing this wrong or am I trying to do the impossible?

EDIT: I have to add that I can load SWF with these URL parameters from the AS2 loader, and it works fine.

+3
source share
5 answers

AS2 AS3, . http://www.gskinner.com/blog/archives/2007/07/swfbridge_easie.html .

: as2, as2 , as3 as2 _root.varname. .

+4

, SWF, , . ...

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, movieLoaded);

function movieLoadedHandler(event : Event) : void
{
    var loaderInfo : LoaderInfo = event.target as LoaderInfo;
    var clip : DisplayObject = loaderInfo.content;

    for each(var prop in varsToTransfer)
    {
        clip[prop] = varsToTransfer[prop];
    }

    // add to parent
}

, .

0

AS3 → AS3

1 (www.domain1.com): , ""...

buy.addEventListener(MouseEvent.CLICK,function(){                   
    var ldr:Loader = new Loader();
    var url:String = "http://www.domain2.com/movie.swf?a=b&c=d";
    var urlReq:URLRequest = new URLRequest(url);
    ldr.load(urlReq);
    addChild(ldr);
    });

2 (http://www.domain2.com/movie.swf):

var mc:MovieClip = this as MovieClip;
var ldi:LoaderInfo = mc.loaderInfo;
var lobj:Object = ldi.parameters as Object;

for (var l in lobj) {
    dumper.htmlText += l+" => "+lobj[l]+"<br />";
}

"dumper" - Dynamic Textbox, Movie2. :

a => b
c => d
0

_root.param _root._url, .

var url: String = _root._url;
var param: String = 'param=';
var paramStart: Number = url.lastIndexOf(param);
var paramValue: String = url.substring(paramStart + param.length, url.length);
trace(paramValue);

SWFBridge - .

0

.

" http://domain/as2.swf?param=foo"

as2.swf, domain. ? Param = foo, http-, , . - , , .swf , .

( ) -, , as2.swf -, , .

I do not own as2, but in as3, the global object can be accessed using the this keyword at the package level (the probability is the same as for as2, just don't worry about installing it at the package level).

-1
source

Source: https://habr.com/ru/post/1702271/


All Articles