6 Replies Latest reply on Jun 9, 2006 7:47 PM by kglad

    what's wrong with this code?

    Level 7
      Don't get any error msg's, just a blank stage. Any ideas what's wrong?

      Frame 1 of Main.swf:
      -------------------------------
      if (init == undefined) {
      var aSWFs:Array = new Array("an1.swf", "an2.swf", "an3.swf");
      var nSWFs:Number = aSWFs.length;
      var nCurSWF:Number = 0;
      var aSWFmcs:Array = new Array();
      for (var n=0; n<=nSWFs; n++) {
      aSWFmcs.push(createEmptyMovieClip("swf"+n, n));
      }
      var mcl:MovieClipLoader = new MovieClipLoader();
      var Listen:Object = new Object();
      Listen.onLoadInit = function(target) {
      trace(target);
      if (nCurSWF <= nSWFs) {
      nCurSWF++;
      // load the next swf
      mcl.loadClip(this.aSWFs[nCurSWF], aSWFmcs[nCurSWF]);
      } else {
      // done loading... start playing
      aSWFmcs[0].gotoAndPlay(2);
      }
      }
      mcl.addListener(Listen);
      mcl.loadClip(this.aSWFs[0], aSWFmcs[0]);

      init = 1;
      }

      ---------------------------
      This code is in each 'called' swf:
      ---------------------------
      Frame 1:
      stop();

      Last Frame:
      stop();
      // if the Current SWF is not the last increment nCurSWF, else set it to
      the start
      if (nCurSWF < nSWFs) {
      nCurSWF++;
      } else {
      nCurSWF = 0;
      }
      aSWFs[nCurSWF].gotoAndPlay(2);
        • 1. Re: what's wrong with this code?
          kglad Adobe Community Professional & MVP
          your first swf should load without problem or you have a path/file name problem in aSWFs. to remedy, use the correct path/file names.

          your subsequent swfs will fail to load because of your use of "this" in this.aSWFs[nCurSWF] within your Listen handler. "this", in that location, refers to Listen and aSWFs are not defined within that scope.

          to remedy, remove the word "this".
          • 2. Re: what's wrong with this code?
            Level 7
            In article <e6bv4k$a6v$1@forums.macromedia.com>,
            webforumsuser@macromedia.com says...
            > your first swf should load without problem or you have a path/file name problem
            > in aSWFs. to remedy, use the correct path/file names.
            >
            > your subsequent swfs will fail to load because of your use of "this" in
            > this.aSWFs[nCurSWF] within your Listen handler. "this", in that location,
            > refers to Listen and aSWFs are not defined within that scope.
            >
            > to remedy, remove the word "this".
            >
            >
            OK... applied remedies and the first gotoAndPlay(2) works... first SWF
            plays through.

            But, subsequent SWFs aren't playing... added a trace and the variables
            are undefined:
            nCurSWF - current swf number
            nSWFs - the total number loaded
            aSWFs - an array of references to the movie clips that the swf's are
            loaded into.

            I tried making them 'public' in the main.swf... that threw an error.
            How do I make those available to all loaded swf's???


            • 3. Re: what's wrong with this code?
              Level 7
              Got the answer (_global variables)
              All three swfs are loading and the first one is playing.


              Here's the last sticking point:
              in each 'loaded swf' the final frame holds this code:

              ------------------------------------------
              stop();
              // if the Current SWF is not the last increment nCurSWF, else set it to
              the start
              if (_global.nCur < _global.nClips) {
              _global.nCur++;
              } else {
              _global.nCur = 0;
              }
              trace(_global.nCur);
              eval("_level0.swf"+_global.nCur+".gotoAndPlay(2)"); <--the problem


              the trace reports the right number
              (loaded swfs are _level0.swf0, _level0.swf1, _level0.swf2)

              if I substitute the hard code .... _level0.swf1.gotoAndPlay(2);
              then the next swf plays.

              What's the right code to accomplish the deed??
              • 5. Re: what's wrong with this code?
                Level 7
                In article <e6d7vm$shb$1@forums.macromedia.com>,
                webforumsuser@macromedia.com says...
                > try:
                >
                >
                >
                > _level0["swf"+_global.nCur].gotoAndPlay(2); // if you're trying to control _level0.swf1, _level0.swf2 etc
                >
                That did it! THANKS
                • 6. Re: what's wrong with this code?
                  kglad Adobe Community Professional & MVP
                  you're welcome.