3 Replies Latest reply on Jul 13, 2010 11:21 PM by aditi_bk

    Loader not linking to the external swf being loaded

    aditi_bk

      Hi,

       

      I am trying to make this website, which has  separate files for different screen resolutions. I am using a first.swf  file to load the right file, depending on the screen resolution, it goes to a different frame for diff resolutions. There I have placed a loadMovie function.

       

      The code for the loader follows the loadMovie call. loadingbar is a movieclip on screen, which presently does nothing.


      _root.loadMovie("filename.swf", mcholder);



      loadingbar.onEnterFrame = function() {


      kBytesLoaded = this._parent.mcholder.getBytesLoaded() / 1024;


      kBytesTotal = this._parent.mcholder.getBytesTotal() / 1024;


      percentage = Math.round(kBytesLoaded / kBytesTotal * 100);


      txt1.text = percentage;


      if (percentage == 100) {


      delete this.onEnterFrame;


      }


      }

       

      This was displaying nothing, so I replaced the _root.loadMovie with mcholder.loadMovie("filename.swf"). This is not working either, the screen flashes

      for one second and then  disappears. I put a stop(); before the code, and the screen remained,  but the movie still did not load.

       

      I txt1.text shows 100. meaning percentage did reach hundred, but I am guessing that is for first.swf, and not for the file which is being loaded. I am still

      learning the ropes and would appreciate it if someone could tell me what I am doing wrong. Any help will be greatly appreciated.

        • 1. Re: Loader not linking to the external swf being loaded
          aditi_bk Level 1

          I have now changed the code to

           

          mcholder.loadMovie("filename.swf");

           

          loadmc.onEnterFrame = function () {
             
          percent = Math.floor((this._parent.mcholder.getBytesLoaded()/ this._parent.mcholder.getBytesTotal())*100);
          prcnt.text = percent+ "%";

           

          if (percent == 100){
          prcnt._alpha =0;   
          loadmc._alpha = 0;
          delete this.onEnterFrame;
          }

           

          }

           

          Now it shows nothing at all. the 'prcnt' textbox displays nothing. It only shows the loadmc movieclip, which is also not playing. What am I doing wrong?? Some one help...!!!!!

          • 2. Re: Loader not linking to the external swf being loaded
            Ned Murphy Adobe Community Professional & MVP

            You should look into using the MovieClipLoader.loadClip method instead of loadMovie... it's made for information-based loading.  Search Google using "AS2 MovieClipLoader tutorial" and you should find some helpful tutorials.

            1 person found this helpful
            • 3. Re: Loader not linking to the external swf being loaded
              aditi_bk Level 1

              Hi Ned,

               

              Thanks for the suggestion. I looked up MovieClipLoader tutorials and finally came up with the code:

               

              var myMCL:MovieClipLoader = new MovieClipLoader();

               

              var loadListener:Object = new Object();

               

              myMCL.addListener(loadListener);

               

              loadListener.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void
              {
                  var perc:Number = (bytesLoaded / bytesTotal) * 100;
                  prcnt.text = perc + " %";
              }

               

              loadListener.onLoadInit = function(target_mc:MovieClip)
              {
                  trace( target_mc + " finished loading so display on screen now. " );
                     
                  prcnt.text = "init";
                 
              };

               

              loadListener.onLoadError = function(target_mc:MovieClip, errorCode:String, httpStatus:Number)
              {
                  trace( "error loading image : errorCode : " + errorCode );
              }

               

               

              loadListener.onLoadStart = function(target_mc:MovieClip)
              {
                  trace( target_mc + " start loading. maybe you want to do something here? " );
                  prcnt.text = "onstart";
              };

               

              myMCL.loadClip("filename.swf", mcholder);  //mcholder is the movie clip holder placed on stage manually

               

              The problem here is that the file does not move beyond

               

              _level0.mcholder start loading. maybe you want to do something here?
              _level0.mcholder start loading. maybe you want to do something here?
              _level0.mcholder start loading. maybe you want to do something here?
              _level0.mcholder start loading. maybe you want to do something here?
              _level0.mcholder start loading. maybe you want to do something here?
              _level0.mcholder start loading. maybe you want to do something here?
              _level0.mcholder start loading. maybe you want to do something here?

               

              Why is this happening? The code is directly from the tutorial. I have included all event functions, in case they are something like abstract functions, I don't know if this is required or not. I know I must be being a pain, but I can't figure out what is wrong with the code, seems simple enough to me. I am sure I am missing some basic point. Any help will be greatly appreciated...