The ActionScript virtual machine that runs ActionScript 3 code (AVM2) is completely different from the ActionScript virtual machin that runs ActionScript 1 and ActionScript 2 code (AVM1). Because of this, you cannot call commands in an AVM1 movie from and AVM2 movie or vise versa. The virtual machines just are not compatible in that respect and mostly run in their own kind of shell that allows it to only interact with code being played back in that same virtual machine. What that boils down to is that ActionScript 3 cannot talk to AS1 or AS2 – at least not directly.
One thing these two virtual machines have in common is their implementation of LocalConnection. Both virtual machines deal with local connections in essentially the same way – enough that local connections in AVM1 can receive events from AVM2 and vise versa. So should you come into a situation where you would need a movie published in ActionScript 3 to communicate with a movie published in ActionScript 1 or 2, using local connection is the way to go.
Example:
// one movie clip animation named animation_mc on the timeline
// local connection instance to receive events
var AVM_lc:LocalConnection = new LocalConnection();
// stopAnimation event handler
AVM_lc.stopAnimation = function(){
animation_mc.stop();
}
// listen for events for “AVM2toAVM1″
AVM_lc.connect(“AVM2toAVM1″);
// local connection instance to communicate to AVM1 movie
var AVM_lc:LocalConnection = new LocalConnection();
// loader loads AVM1 movie
var loader:Loader = new Loader();
loader.load(new URLRequest(“AS2animation.swf”));
addChild(loader);
// when AVM1 movie is clicked, call stopPlayback
loader.addEventListener(MouseEvent.CLICK, stopPlayback);
function stopPlayback(event:MouseEvent):void {
// send stopAnimation event to “AVM2toAVM1″ connection
AVM_lc.send(“AVM2toAVM1″, “stopAnimation”);
}
The AS3 movie loads the AS2 movie into a Loader instance and places it on the screen. As it plays, the user can click the animation which calls stopPlayback sending the “stopAnimation” event to the local connection named “AVM2toAVM1″. The AS2 movie is then able to receive that event in its stopAnimation event handler and tell the animation_mc clip to stop.



