2 Replies Latest reply on May 30, 2007 6:55 PM by hutch-diggens

    Resizing/fading dynamic gallery issues...

    hutch-diggens
      Hey there. I'm kind of in a huge deadline crunch.

      I have a gallery that I built from a tutorial I found online--it has an empty mc with a border around it, and when you click on a thumbnail an image is loaded into the mc and it fades in when it loads in and out.

      Ofcourse it works fine offline, but when I test it online the image will load in off-center, if you click the thumbnail again (after it has loaded the first time) it loads in the position it should be in.

      Here is the code I have on the first frame:
      spacing = 1;
      containerMC._alpha = 0;

      MovieClip.prototype.loadPic = function(pic){
      containerMC._alpha = 0;
      this.loadMovie(pic);
      onEnterFrame = function(){
      var t = containerMC.getBytesTotal(), l = containerMC.getBytesLoaded();
      if (t != 0 && Math.round(l/t) == 1){
      var w = containerMC._width + spacing, h = containerMC._height + spacing;
      border.resizeMe(w, h);
      delete this.onEnterFrame;
      }
      }

      };
      MovieClip.prototype.resizeMe = function(w, h) {
      var speed = 3;
      this.onEnterFrame = function() {
      this._width += (w-this._width)/speed;
      this._height += (h-this._height)/speed;
      if (Math.abs(this._width-w)<1) {
      this._width = w;
      this._height = h;
      containerMC._x = this._x-this._width/2+spacing/2;
      containerMC._y = this._y-this._height/2+spacing/2;
      containerMC._alpha += 5;
      if (containerMC._alpha>90) {
      containerMC._alpha = 100;
      delete this.onEnterFrame;
      }
      }
      };
      };

      and here is the code that I have on my btns:
      on(release){
      _parent.containerMC.loadPic("pic_001.jpg");
      }

      Any suggestions???
      I really need some quick help on this one.

      Thanks so much in advanced!!!

      hutch.
        • 1. Re:  Resizing/fading dynamic gallery issues...
          crazyjoemilan Level 2
          so without analyzing your code, it looks like a procedural thing. Anytime you have something that works fine everytime after the first means your initial resize/place function is being called too early. Look at the order of your code if your image was to take a long time to load, and see if you find what I'm talking about. If not, we'll look further into it.

          HmcH
          • 2. Re:  Resizing/fading dynamic gallery issues...
            hutch-diggens Level 1
            I changed some of the code around and have been trying to trouble shoot this for a while. Here is the code I have now:

            spacing = 10;
            containerMC._alpha = 0;

            MovieClip.prototype.loadPic = function(pic){
            containerMC._alpha = 0;
            this.loadMovie(pic);
            onEnterFrame = function(){
            var total = Math.round(containerMC.getBytesTotal()/1024);
            var loaded = Math.round(containerMC.getBytesLoaded()/1024);
            if (total != 0 && loaded>=total){
            var w = containerMC._width + spacing;
            var h = containerMC._height + spacing;
            border.resizeMe(w, h);
            delete this.onEnterFrame;
            }
            }
            };
            MovieClip.prototype.resizeMe = function(w, h) {
            var speed = 3;
            this.onEnterFrame = function() {
            this._width += (w-this._width)/speed;
            this._height += (h-this._height)/speed;
            if( Math.abs(this._width-w)<1 && Math.abs(this._height-h)<1){
            this._width = w;
            this._height = h;
            containerMC._x = this._x-this._width/2+spacing/2;
            containerMC._y = this._y-this._height/2+spacing/2;
            containerMC._alpha += 5;
            if (containerMC._alpha>90) {
            containerMC._alpha = 100;
            delete this.onEnterFrame;
            }
            }
            };
            };

            And I'm pretty sure the issue of the image loading messed up on the first time is because of the last bit of code for the fade in--
            if (containerMC._alpha>90) {
            containerMC._alpha = 100;
            delete this.onEnterFrame;
            }
            but, I'm not exactly sure how to fix it. I took it out and just had the images load in with no fade and it seemed to work fine with no weird loads on the first clicks----but I would really like to incorporate the fade, it just adds that little something that I need in this site.

            Any thoughts????
            thanks,
            hutch