2 Replies Latest reply on May 11, 2006 2:12 PM by abeall

    loadMovie fails

    abeall Level 3
      I am using Flash 8 and publishing to SWF6, AS1.0. I have switched up publish settings and doesn't seem to change anything.

      This script:

      var dZ = _root.createEmptyMovieClip("dropZone_mc",10101);
      dZ.loadMovie("survey.swf");

      onEnterFrame = function(){
      trace(dZ)
      trace(dZ.loadFrame) //this is defined on frame 1 of survey.swf
      trace(dZ._framesloaded)
      trace(dZ._totalframes)
      trace(dZ.getBytesLoaded())
      trace(dZ.getBytesTotal())
      var loaded = dZ._framesloaded;
      var total = dZ.loadFrame;
      var percent = Math.min(100,Math.ceil((loaded/total)*100));
      var f = Math.ceil(loadBar_mc._currentframe+((percent-loadBar_mc._currentframe)/6));
      loadBar_mc.gotoAndStop(f);
      if(loadBar_mc._currentframe>=99 && dZ._totalframes>1){
      _root.gotoAndPlay("start");
      delete onEnterFrame;
      }
      }

      Fails to load the SWF in the IDE at all. If I test movie, I get the following trace:
      _level0.dropZone_mc
      undefined
      -1
      0
      0
      -1
      _level0.dropZone_mc
      undefined
      226
      226
      421849
      421849

      ^ code after second "_level0.dropZone_mc" repeats endlessly

      If I test movie and simulate download, I get this:

      _level0.dropZone_mc
      undefined
      -1
      0
      0
      -1
      _level0.dropZone_mc
      undefined
      -1
      226
      2011
      421849

      ^ again, the second half repeats itself, with "2011" - which is getBytesLoaded() - slowly increasing, but not accurate to the download speed, and it goes slower and slower untill it kind of crawls to a stop before reaching getBytesTotal().

      In the first example, we see that on frame 1 the loadMovie has not initialized, and on frame 2 it has completed(since it's a local load). Expected behavior. But we see that the variable "loadFrame" is undefined. Why? It is properly defined on frame 1 of survey.swf. Also, if I re-test that, 90 percent of the time the variable loadFrame comes through fine. Why would it come through sometimes and not others??

      More disturbing is the second example, with simulate download on. In frame 1 we see again loadMovie is not initialized. In frame 2, we see that it is being loaded(or something) because getBytesLoaded, getBytesTotal and _totalframes are returning values, but _framesloaded persistently returns -1. What is that?? And why the odd getBytesLoaded behavior?

      I have loaded and preloaded movies for years, and this makes no sense to me.
        • 1. Re: loadMovie fails
          blemmo Level 1
          Hi beally,

          it might not be the solution to your problem, but don't forget the code execution order of Flash: the code in the loaded movie only executes when all the code in the loading frame is done. That means that 'loadFrame' in survey.swf will only be defined after the loading code finished, so you shouldn't use it in the preloader code. As you saw, the loading doesn't finish (execute _root.gotoAndPlay("start")), because it depends on 'loadFrame'.
          I don't know if this causes this strange behaviour, but you might try to take that out and see what happens.

          cheers,
          blemmo
          • 2. Re: loadMovie fails
            abeall Level 3
            Thanks.

            The thing is, the loadFrame var is being accessed in an onEnterFrame that is not attached to the loaded movieclip, so it's shouldn't be a problem. Naturally, there will be a delay while the loadFrame has not been loaded, but the onEnterFrame will keep checking. And like I said, it works 90 percent of the time.