7 Replies Latest reply on May 18, 2007 6:54 AM by kglad

    progress bar question

    crila
      i am loading a .jpg into a holder movie clip. easy enough. but i want a progress bar that will show the progress then go away when it is complete. im trying to use an if statement to get it to disappear, but i dont know what i should put in the if part. here is my code...

      one.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
      function mouseDownHandler(event:MouseEvent):void {
      var pictLdr:Loader = new Loader();
      var pictURL:String = "images/1.jpg"
      var pictURLReq:URLRequest = new URLRequest(pictURL);
      pictLdr.load(pictURLReq);
      holder.addChild(pictLdr);

      //loading bar
      var dataPath:String = "images/1.jpg";
      var loader:URLLoader = new URLLoader();
      loader.load(new URLRequest(dataPath));
      var pb:ProgressBar = new ProgressBar();
      pb.source = loader;
      addChild(pb);
      pb.x = 100
      pb.y = 200

      if (??????? == ????) {
      removeChild(pb);
      }
      }

      any suggestions????
        • 1. Re: progress bar question
          crila Level 1
          well i figured it out....so ill answer my own question in case it can help someone else. i didnt use an if statement...i used a function statement instead. heres what it looks like...

          one.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
          function mouseDownHandler(event:MouseEvent):void {
          var pictLdr:Loader = new Loader();
          var pictURL:String = "images/1.jpg"
          var pictURLReq:URLRequest = new URLRequest(pictURL);
          pictLdr.load(pictURLReq);
          holder.addChild(pictLdr);

          //loading bar
          var dataPath:String = "images/1.jpg";
          var loader:URLLoader = new URLLoader();
          loader.load(new URLRequest(dataPath));
          var pb:ProgressBar = new ProgressBar();
          pb.source = loader;
          addChild(pb);
          pb.x = 100
          pb.y = 200

          //remove bar
          pb.addEventListener(Event.COMPLETE, completeHandler);
          function completeHandler(event:Event):void {
          pb.removeEventListener(Event.COMPLETE, completeHandler);
          removeChild(pb);
          }
          }

          hope that can help someone
          • 2. Re: progress bar question
            kglad Adobe Community Professional & MVP
            you don't need to use a Loader() and an UILoader(). just use the UILoader() alone.
            • 3. Re: progress bar question
              crila Level 1
              not following you there. what lines would i need to take out?
              • 4. Re: progress bar question
                kglad Adobe Community Professional & MVP
                :

                • 5. Re: progress bar question
                  crila Level 1
                  when i apply that code i get this error...

                  1067: Implicit coercion of a value of type flash.net:URLLoader to an unrelated type flash.display:DisplayObject.
                  • 6. Re: progress bar question
                    crila Level 1
                    oh yeah it was referring to this line...

                    holder.addChild(pictLdr);

                    (the one right above the //loading bar line)
                    • 7. Re: progress bar question
                      kglad Adobe Community Professional & MVP
                      you're correct. you can't use a URLoader object as a display object (and you can't use a Loader object with the progressbar component).

                      so, you're supposed to use the UILoader component with the progressbar component when you have something you want to load and you want to add to the display list.