[Flashcoders] MovieClipLoader, onLoadInit: not working properly / bug
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;} / The main swf has the following: 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); / Now, I know what you are saying... This should work... And it does - usually... But then I ran into this perplexing problem. In trying to resolve this issue I did the following: 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 } } /// Setting up the interval, essentially an onEnterFrame, the onLoadInit worked as it should, where the code in frame 1 of the swf had executed. I see this as a HUGE ISSUE, in the fact that MovieClipLoader might not be reliable. Has ANYBODY run into this? Or know of what might cause it. We are publishing to the main swf to v7, external swfs are v6 and v7, and this issue has appeared when playing back on player 8 and 9. I haven't been able to duplicate the issue on v7... Actually I haven't been able to duplicate it at all, but my client has and has consistently. I don't expect anybody to really know the answer, because I'm sure that when/if you try it, it will work as expected. But if you could theorize about why this might happen... Or what set of circumstances might have occurred to cause onLoadInit to fail, or execute too early - I'd greatly appreciate it? Thanks for your time! Cheerio! Drew Shefman ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: 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
Re: [Flashcoders] MovieClipLoader, onLoadInit: not working properly / bug
hmm...you said the external swf's are 6 and 7...do youknowif it's only the version 6 swfs giving you the propblem? or is it both? just trying to isolate. On 10/28/06, Drew Shefman [EMAIL PROTECTED] wrote: 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;} / The main swf has the following: 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); / Now, I know what you are saying... This should work... And it does - usually... But then I ran into this perplexing problem. In trying to resolve this issue I did the following: 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 } } /// Setting up the interval, essentially an onEnterFrame, the onLoadInit worked as it should, where the code in frame 1 of the swf had executed. I see this as a HUGE ISSUE, in the fact that MovieClipLoader might not be reliable. Has ANYBODY run into this? Or know of what might cause it. We are publishing to the main swf to v7, external swfs are v6 and v7, and this issue has appeared when playing back on player 8 and 9. I haven't been able to duplicate the issue on v7... Actually I haven't been able to duplicate it at all, but my client has and has consistently. I don't expect anybody to really know the answer, because I'm sure that when/if you try it, it will work as expected. But if you could theorize about why this might happen... Or what set of circumstances might have occurred to cause onLoadInit to fail, or execute too early - I'd greatly appreciate it? Thanks for your time! Cheerio! Drew Shefman ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: 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 ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: 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
RE: [Flashcoders] MovieClipLoader, onLoadInit: not working properly / bug
Hi On the same line as Rich's question. Version 6 SWFs use a different security sandbox then v7 SWFs and thus you can get some interesting side effects. One such side-effect is if you try to query said clip it should return null or 0 for things like _bytesLoaded, _bytesTotal etc. The same type of thing happens when mixing version 7 and version 8 swfs. For best results and reliability, a project should attempt to use swfs of all the same version and from the same subdomain/domain to prevent goofy things. Another thing that might have an impact on the firing of onLoadInit is if a shared library is referenced by the swf. If I remember right, MovieClipLoader will load the swf but not its shared libraries. Thus there is an extended delay after loading in which the first frame cannot execute because it needs to load any items in a shared library (if referenced on that frame). I believe one of my coworkers noticed that in this case, onLoadInit occurs before the first frame executes as well. So beaware that the shared library thing can have a negative effect even if all swfs come from the same server and are the same version. Sincerely Mark R. Jonkman ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: 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