Sunday, April 29, 2012

AS2.0 and AS3.0 Communication without local connection

It has always been challenging to load as2.0 file in as3.0 movie, and controlling it. Since lot of our previous work we did was in older version of Flash which used as2.0 as their scripting standard, it has caused many animations, e-learning frames etc available to us in as2.0.

There are two ways you can load and connect between as2.0 and as3.0 files.
  1. Using Local Connection
  2. Loading as2.0 file by converting it to new AVM
In this blog I will focus only on the second option which has its own benefit and advantage. The movie file created from older version of flash(using as2.0) uses AVM1 for display whereas AVM2 is the latest virtual machine used by latest version of flash(using as3.0). The difference in these virtual machine causes limitation while communication as2.0 and as3.0 file.

We would load one AS2.0 animation in AS3.0 file and try to control it from the buttons in AS3.0 file. To load the AS2.0 file we will use AVM2Loader.as http://troyworks.com/blog/2007/09/17/avm2loader-converting-avm1-to-avm2/.

Lets create our AS3.0 file which will be used to load & control the AS2.0 file.

/* code utilizing the  AVM2Loader class */


var _frameWorkReq:URLRequest  = new URLRequest("as2.swf")
var _frameWork_loader = new AVM2Loader();

_frameWork_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
_frameWork_loader.load(_frameWorkReq);

addChild(_frameWork_loader)

You can click here to download the AS3.0 Loader file.

Once our AS2.0 file is loaded, we use use "LoaderInfo" to access the loaded swf file and control it accordingly. Below code would explain the funda being talked here.


var info:LoaderInfo = event.target as LoaderInfo;
controlerClip = MovieClip(info.content);



All the related files can be downloaded by clicking here.

- Nitin


Using FormBuilder, Validators & FormGroup in Angular 2 to post data to Node server (node.js)

This blog explains usage of  FormBuilder , Validators , FormGroup classes in Angular 2 projects. In this post we will create HTML form a...