2 Replies Latest reply on Jul 26, 2006 12:11 PM by devunit

    Why not working in Flash 7?

    devunit
      I'm a novice AS trying to figure out why this works when I publish in Flash 6 but not 7 or 8. I'd appreciate any insight. Also, I've been looking for a site/source which details the diferences between 6 and 7, any suggestions.

      onClipEvent (load){
      k= 0.95; //springy
      damp = 0.9; //friction
      orgzx = _width; //orig width
      orgzy = _height;// original height
      zx = _width; //new height
      zy = _height; //new height
      lower = _x-(_width*0.5); //left half of clip
      higher = _x+(-width*0.5); //right half
      top = _y -(_height*0.5); //top half of clip
      bottom = _y+(_height*0.5);//bottom half of clip
      scale = 1.45;//amount change
      }
      onClipEvent (enterFrame){
      inside = (_root._xmouse >= lower) && (_root._xmouse <= higher);
      outside = (_root._xmouse < lower) || (_root._xmouse > higher);
      func = (_root._ymouse < top) || (_root._ymouse > bottom);
      if (inside) {
      zy = orgzy * scale;
      }
      if (outside){
      zx = orgzx;
      zy = orgzy;
      }
      if (func){
      zx = orgzx;
      zy = orgzy;
      }
      ax = (zx-_width)*k; //rate
      vx += ax;
      vx *= damp;
      _width += vx;
      ay = (zy-_height)*k;
      vy += ay;
      vy *= damp;
      _height += vy;
      }
        • 1. Re: Why not working in Flash 7?
          Level 7

          "devunit" <webforumsuser@macromedia.com> wrote in message
          news:ea80dj$j30$1@forums.macromedia.com...
          > I'm a novice AS trying to figure out why this works when I publish in
          > Flash 6
          > but not 7 or 8. I'd appreciate any insight. Also, I've been looking for a
          > site/source which details the diferences between 6 and 7, any suggestions.
          >

          Try this modified code.

          There were a few problems with yours including not having the underscore _
          in the line
          higher = _x+(-width*0.5); //right half
          for the _width.

          also, you can't do math like
          varName+(-varName2 * 5);
          it has to be
          varName - (varName2 * 5);
          or
          varName + (-1 * varName2 * 5); varName + (varName2 * - 5);

          Also, you need to instatiate your variables. You can't just start saying in
          a loop
          x += 1;
          if x is undefined. It will become NAN.
          Instead,
          var x:Number = 0;
          for ... {
          x += 1;
          }



          My code is expecting the movie to be registered at 0, 0 whereas yours was
          expecting it in the center. You can just change what i have to get your
          values right for higher, lower, top, bottom and the acceleration values ax,
          ay.

          I also commented out the _xscale because I like to look at it like a hanging
          spring, not a big spring blob.

          Hope this helps.
          Sean



          onClipEvent (load){
          var k= 0.95; //springy
          var damp = 0.9; //friction
          var orgzx = _width; //orig width
          var orgzy = _height;// original height
          var zx = _width; //new height
          var zy = _height; //new height
          var lower = _x; //left half of clip
          var higher = _x + _width; //right half
          var top = _y; //top half of clip
          var bottom = _y + _height;//bottom half of clip
          var scale = 1.45;//amount change
          var vx = 0;
          var vy = 0;
          }

          onClipEvent (enterFrame){
          inside = (_root._xmouse >= lower) && (_root._xmouse <= higher);
          outside = (_root._xmouse < lower) || (_root._xmouse > higher);
          func = (_root._ymouse < top) || (_root._ymouse > bottom);
          if (inside) {
          zy = orgzy * scale;
          }
          if (outside){
          zx = orgzx;
          zy = orgzy;
          }
          if (func){
          zx = orgzx;
          zy = orgzy;
          }
          ax = (zx-_width/2)*k; //rate
          vx += ax;
          vx *= damp;
          //_width += vx;
          ay = (zy-_height/2)*k;
          vy += ay;
          vy *= damp;
          _height += vy;

          }


          • 2. Re: Why not working in Flash 7?
            devunit Level 1
            Thanks Sean.
            You cleared that up. It works now although my clip is scaled before rolling over it for some reason.

            Why was it not necessary to instantiate the rate (ax)?

            Dev