3 Replies Latest reply on Jun 6, 2007 6:17 PM by kglad

    ProgressEvent AS3

    Natan Alves
      In AS2, i can import a MovieClip from library using the attachMovie, and in this MovieClip i can use the MovieClipLoader Class to load a image and show the progress (using a MovieClip that is inside the MovieClip imported). Example:

      var mcl:MovieClipLoader = new MovieClipLoader();
      var mclListener:Object = new Object();
      var mc:MovieClip = _root.attachMovie("myMc", "myMc"+i, _root.getNextHighestDepth());
      mcl.loadClip("image"+i, mc.holder);
      mvl.addListener(mclListener);
      mclListener.onLoadProgress = function(target_mc, loadedBytes, totalBytes) {
      target_mc._parent.bar._yscale = loadedBytes/totalBytes*100;
      }

      Where, holder is a MovieClip that is in the MovieClip myMc and bar is a MovieClip that is in the MovieClip myMc. With this, for each MovieClip that is imported i can show the load progress.

      Now in AS3 i am not obtaining the progress from this images, i even can't say to Flash where is the target to scale. I am using this:

      var loader:Loader = new Loader();
      var mc:MovieClip = new myMc();
      addChild(mc);
      mc.holder.addChild(loader);
      loader.load(new URLRequest("image"+i));
      loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
      function loadProgress(evt:ProgressEvent) {
      var loaded:Number = evt.bytesLoaded;
      var total:Number = evt.bytesTotal;
      mc.bar.width = loaded/total;
      }

      The Flash don´t show the progress from the image and apears errors on the Output panel. Somebody already passed for this problem of migration and have a soluction?

      Sorry for my english.

      Thanks
        • 1. Re: ProgressEvent AS3
          kglad Adobe Community Professional & MVP
          if i is defined, myMc is the class name of a movieclip in your library that contains child movieclips holder and bar, then you shouldn't see any output errors.

          you won't see you mc.bar do much because you're adjusting its width from 0 to 1. you could use the scaleX property of mc.bar and that would give you the result you probably want.
          • 2. Re: ProgressEvent AS3
            Natan Alves Level 1
            Hey man, thanks for the answer, but i think you doesn't understand.

            I can't in the funcion loadProgress access the MovieClip bar that is in the MovieClip myMc that is imported from my library. Diferent from AS2 where i can access the target from the functon onLoadProgress now in AS3 i can't do this. And the error that appears is this: "Access of undefined property mc"

            Thanks
            [ ]s
            • 3. Re: ProgressEvent AS3
              kglad Adobe Community Professional & MVP
              then the movieclip in your library that's a member of myMc doesn't have a child movieclip with instance name bar.