8/3/2010 8:29:41 PM
Title:
Load, play, pause AVM1 content in AVM2 parent
I need make a AS3 project that load other swf files and play, pause them. The problem is some files are made by AS1 (AVM1 content) and I can't cast them to movieclip object to play, pause it.
Could anybody help suggest a workaround or a fix for this issue?
Best Regards,
meoden8x
Inder
Points: 2980
Posts:0
8/3/2010 10:33:55 PM
unfortunately AS3 does not support direct communication with AS1 content. So you need to create a AS1 player which can be loaded into as3 project. Now write code in the player with local connection to communicate with as3 - as1. Now the as3 will use the local connection to call the functions inside the as1 player . the functions inside the player will do the loading of as1 content and controlling , play , pause etc.
write this code to create local connection in as3
// ActionScript 3
// local connection to communicate to AVM1 player
var AVM_lc:LocalConnection = new LocalConnection();
// loader loads AVM1 player
var loader:Loader = new Loader();
loader.load(new URLRequest("player.swf"));
addChild(loader);
// call this function on as3 button to stop animation
function stopMovie(event:MouseEvent):void {
// ask player to stop loaded animation
AVM_lc.send("AVM2toAVM1", "stopAnimation");
}
code in player swf, I just created a function to stop movie, you can write the functions to load, play also
// local connection in player to receive events from as3
var AVM_lc:LocalConnection = new LocalConnection();
// stopAnimation event handler , called from as3, sim ilarly write functions for loading swf , or pausing swf
AVM_lc.stopAnimation = function(){
//loaded animation in this player
animation_movie.stop();
}
// connect the local connection "AVM2toAVM1"
// remember the name "AVM2toAVM1" should be unique on a computer so only one swf of this can work on same system
AVM_lc.connect("AVM2toAVM1");