4 Replies Latest reply on Nov 20, 2007 7:36 AM by kglad

    Loading problem?

    niki tsanov
      Hello.I try to get bytesTotal and bytesLoaded of my dynamic load images and put some effect into them.Everything is cool but the script get parms and put effect only for the last one.Here my script to understand what i mean well.
      import mx.transitions.Tween;
      // Variables for X and Y position
      // Maximum pictures on dir.
      var min = 1;
      var max = 14;
      var xpos = 0;
      var ypos = 0;
      // Loading pictures into stage
      for (min; min<=max; min++) {
      var mc:MovieClip = createEmptyMovieClip("mov"+min, this.getNextHighestDepth());
      mc.loadMovie(min+".jpg");
      mc._x = xpos;
      mc._y = ypos;
      // Check if pictures is 4 per row
      if (min%4 == 0) {
      xpos = 0;
      ypos += 67;
      } else {
      xpos += 100;
      }
      // Try to get bytes from loaded picture
      loadMC(mc);
      }
      function loadMC(mc:MovieClip) {
      this.onEnterFrame = function() {
      var tkb = mc.getBytesTotal();
      var lkb = mc.getBytesLoaded();
      var per = Math.round((lkb/tkb)*100);
      if (per == 100) {
      fade(mc);
      delete this.onEnterFrame;
      }
      };
      }
      // Some effect
      function fade(mc:MovieClip) {
      var myTween:Tween = new Tween(mc, "_alpha", mx.transitions.easing.None.easeOut, 0, 100, 2, true);
      }