loading external movie as2 wrapper
Load AS2 SWF Into AS3 SWF and pass vars in URL
I'm trying to load in a as3 file an external as2 swf file (of which I dont have access to fla file). According to the explanation given in the link above, the solution would be to use a as2 wrapper to the original as2 file (and establish a localconnection between the the as3 and as2 files). I've tried to do that, but althou开发者_运维问答gh the movie seems to load in my as3 file, it doesnt start, doesnt play and gets stuck in the first frame. How do I play the movie (as well as load it)? Thanks for your help.
My as3 file is:
import com.gskinner.utils.SWFBridgeAS3;
var loader = new Loader()
loader.load(new URLRequest("as2_test.swf"));
addChild(loader);
var sb1:SWFBridgeAS3 = new SWFBridgeAS3("test",this);
my as2 file is:
import com.gskinner.utils.SWFBridgeAS2;
var sb1 = new SWFBridgeAS2("test",this);
sb1.addEventListener("connect",this);
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(this);
loader.loadClip("digestive.swf", mainLoader_mc);
EDIT: I keep having this problem. This is what I have so far:
as2 file - as2test.fla (this needs to download another as2 file -digestive.sfw and acts as wrapper to establish connection between the original as2 file and the main as3 file)
import com.gskinner.utils.SWFBridgeAS2;
var sb1 = new SWFBridgeAS2("test",this);
sb1.addEventListener("connect",this);
var my_pb:mx.controls.ProgressBar;
my_pb.mode = "manual";
this.createEmptyMovieClip("img_mc22", 999);
var my_mcl:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
mclListener.onLoadStart = function(target_mc:MovieClip):Void {
my_pb.label = "loading: " + target_mc._name;
};
mclListener.onLoadProgress = function(target_mc:MovieClip, numBytesLoaded:Number, numBytesTotal:Number):Void {
var pctLoaded:Number = Math.ceil(100 * (numBytesLoaded / numBytesTotal));
my_pb.setProgress(numBytesLoaded, numBytesTotal);
trace(pctLoaded);
};
my_mcl.addListener(mclListener);
my_mcl.loadClip("digestive.swf", img_mc22);
stop();
as3 file (this plays the as2 wrapper):
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
function startLoad()
{
var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest("as2test.swf");
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
mLoader.load(mRequest);
}
function onCompleteHandler(loadEvent:Event)
{
addChild(loadEvent.currentTarget.content);
}
function onProgressHandler(mProgress:ProgressEvent)
{
var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
trace(percent);
}
startLoad();
stop();
In the as2 wrapper file, the original movie plays until a certain frame; in the as3 file, the as2 wrapper file only plays the first frame. What do I have to do?????
精彩评论