Call to an AS2 function from the AS3 container?

If your container absolutely has to be written in AS3, then you could create another intermediary container in AS2 that can communicate with the 1000 existing SWFs directly, and you can then communicate with that using the LocalConnection technique.

If your container absolutely has to be written in AS3, then you could create another intermediary container in AS2 that can communicate with the 1000 existing SWFs directly, and you can then communicate with that using the LocalConnection technique. The code below is a simple example of this, but due to an issue with the MovieClipLoader seeming to not fire events when loaded into an AS3 AVM1 object I have had to implement a rather ugly polling system. The question relating to this issue can be found be here: Why do MovieClipLoader events not fire when loaded into an AS3 wrapper?.

Child_as2. Swf - One of a thousand AS2 files that we are trying to load. It has defined functions on it's root that we want to access when it is loaded: stop(); function playMovie() { play(); } parent_as2.

Swf - The intermediary AS2 file that contains LocalConnection code to bridge between the AVM1 and AVM2 runtimes. Due to the events issue noted above, this polls child_as2. Swf to detect both when it is loaded and when a known function on the root is available.It is important that the first polling call to checkProgress is disregarded as this will return incorrect progress values as noted here: http://help.adobe.com/en_US/AS2LCR/Flash_10.0/00001380.html var container:MovieClip = createEmptyMovieClip("container", 10); var mcLoader:MovieClipLoader = new MovieClipLoader(); var loadStarted:Boolean; var checkingInt:Number; function checkProgress() { var progObj:Object = mcLoader.

GetProgress(container); if(progObj. BytesLoaded == progObj. BytesTotal && loadStarted) { //load complete, wait for loadInit if(typeof(container.

PlayMovie) == "function") { //loadInit clearInterval(checkingInt); container.playMovie(); } } //ensures the first loop is ignored due to inaccuracy with reporting loadStarted = true; } //LocalConnection code var myLC:LocalConnection = new LocalConnection(); myLC. LoadChild = function() { loadStarted = false; mcLoader. LoadClip("child_as2.

Swf", container); checkingInt = setInterval(checkProgress,5); } myLC. Connect("AVM"); parent_as3. Swf - The outer AS3 wrapper.

This loads parent_as2. Swf into an AVM1 object, and communicates with it via LocalConnection. Var myLC:LocalConnection = new LocalConnection(); var loader:Loader = new Loader(); loader.

ContentLoaderInfo. AddEventListener(Event. INIT,onLoaded); loader.

Load(new URLRequest("parent_as2. Swf")); addChild(loader); function onLoaded(event:Event):void { //setTimeout hack to circumvent #2000 Security context error setTimeout(function() { myLC. Send("AVM", "loadChild"); },1); }.

– Tegeril Nov 9 '11 at 17:15 this could be a solution, I'll take a look soon! – vitto Nov 9 '11 at 17:23 @vitto - I've started testing it myself, and come across an issue with MovieClipLoader events in the intermediary container. Might be a deal breaker... – shanethehat Nov 9 '11 at 17:57 2 @vitto - you can see my test setup and the issue I'm experiencing here: stackoverflow.com/questions/8069634/… – shanethehat Nov 9 '11 at 18:24 Bunch of up votes for investigating this so thoroughly.

– Tegeril Nov 9 '11 at 21:28.

I do not envy this situation one bit. The only suggestion I have is to decompile the… 1000 SWFs and implement the LocalConnection logic there, perhaps in a shared SWC if architected properly, recompile the SWFs and go from there.

You can make a as2 swf to make the localconnections. This swf can call your external as2 files and return responces to as3 file. Example below, hope it helps.

The code block below from a project that I did before. It was using as2 file to connect server. Cut out some block of codes hope you can sort out the solution.

// AS3 FILE // local connection instance to communicate to AVM1 movie var AVM_lc:LocalConnection = new LocalConnection(); AVM_lc. Client = this; // loader loads AVM1 movie var loader:Loader = new Loader(); loader. Load(new URLRequest("log2.

Swf")); //addChild(loader); // when AVM1 movie is clicked, call stopPlayback stage. AddEventListener(MouseEvent. CLICK, stopPlayback); function stopPlayback(event:MouseEvent):void { // send login event to "AVM2toAVM1" connection AVM_lc.

Send("AVM2toAVM1", "logIn","[email protected]" , "123123"); } function resulFunc(a:*){ trace(a + " *-*-*-*-"); } AVM_lc. Connect("AVM1TO"); // AS2 FILE - log2. Swf var AVM_lc:LocalConnection = new LocalConnection(); AVM_lc.

LogIn = function(a , b){ trace("login : " , a , " - " , b); } AVM_lc. Connect("AVM2toAVM1"); function sendDataToAs3():Void{ AVM_lc. Send("AVM1TO", "resulFunc", "test value"); }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions