I've run into an issue with MovieClipLoader, that I haven't been able to
find an mention of anywhere else online.
The issue is with the onLoadInit firing before the first frame actionscript
has executed. The issue was repeatable, but only on specific machines, and
ONLY through the browser. When played in the IDE or EXE then it worked as
expected. I personally was not able to see this error, but it happened
consistently on my client's internal network.
Here is the issue:
The external swf files have AS on frame 1:
//>
var myClass:CustomClass = new CustomClass();
function getInstance():CustomClass { return myClass;}
var holder_mc:MovieClip
var myMCL:MovieClipLoader = new MovieClipLoader();
myMCL.addListener(this)
function onLoadInit(p_target)
{
var myInst:CustomClass = holder_mc.getInstance();
if (myInst == undefined)
{
trace("Error, your file doesn't contain the appropriate class");
}
else
{
//Working as it should
}
}
myMCL.loadClip("myUrl.swf",holder_mc);
private var loadInitInterval:Number;
private var doLoadInitCount:Number = 0;
function onLoadInit()
{
doLoadInit()
}
function doLoadInit()
{
clearInterval(loadInitInterval);
var myInst:CustomClass = holder_mc.getInstance();
if (myInst == undefined)
{
//Let's try waiting for a couple of frames
if (doLoadInitCount > 1)
{
trace("Error, your file doesn't contain the appropriate class");
}
else
{
var duration:Number = 1/30*1000 * 2 // wait for 2 frames at
30 fps
clearInterval(loadInitInterval);
loadInitInterval = setInterval(this,"doLoadInit", duration)
}
doLoadInitCount++
}
else
{
//Working as it should
}
}
//http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com