3 Replies Latest reply: Aug 14, 2009 2:13 PM by Smef RSS

    Unloading my progress bar

    BearHNC Community Member

      I  have have applied the progress bar from the componets panel in Flash CS3 using AS2 and I have been able to make it function: however, I have not been successful in getting the progress bar to unload once my file loads. I have tried a couple of things like using an if statement and the unLoadMovieClip but I seem to be wording the code wrong because neither have worked at all, they even have cancelled out all the other code. Can anyone help me write this statemen correctly? Here is my code:

       


      /**
        Requires:
         - Loader component on Stage (instance name: my_ldr)
         - ProgressBar component on Stage (instance name: my_pb)
      */

       

      System.security.allowDomain("ModularWebsite.swf");

       

      var my_ldr:mx.controls.Loader;
      var my_pb:mx.controls.ProgressBar;

       

      my_pb.source = my_ldr;
      my_ldr.autoLoad = false;
      my_ldr.contentPath = "ModularWebsite.swf";

       

      // when autoLoad is false loading does not start until load() is invoked
      my_ldr.load();

        • 1. Re: Unloading my progress bar
          Smef Community Member

          I think the code you are looking for is removeMovieClip(movieclip);

          • 2. Re: Unloading my progress bar
            BearHNC Community Member

            I wound up doing this instead:

             

            var img_mcl:MovieClipLoader = new MovieClipLoader();
            var mclListener:Object = new Object();
            mclListener.onLoadProgress = function(target_mc:MovieClip, numBytesLoaded:Number, numBytesTotal:Number) {
                my_pb.setProgress(numBytesLoaded, numBytesTotal);
            };
            mclListener.onLoadComplete = function(target_mc:MovieClip) {
            my_pb._visible = false;
            };
            img_mcl.addListener(mclListener);
            this.createEmptyMovieClip("image_mc", 20);
            img_mcl.loadClip("ModularWebsite.swf", image_mc);

            • 3. Re: Unloading my progress bar
              Smef Community Member

              What you are doing is just making the MC invisible, not actually removing it from the scene.

               

              if you enter:

               

              removeMovieClip(my_pb);

               

              your movie clip will actually be removed, reducing (even if only slightly) the resources needed to run your flash movie.