4 Replies Latest reply on Jan 17, 2007 10:36 AM by Newsgroup_User

    Animated Height and Width

    quadpolar
      I'm trying to write lingo, that tells a certian object, upon the mouse leaving, to scale down by x amount. However I want it to be animated and happen over time. But I want it to all be in Lingo, within the cast member. I have it looking like this right now, but this just makes it go from one size, immediately to a smaller size. Like I said, I would like this to happen over a period of say, .5 seconds.

      on mouseLeave me
      sprite(2).height = 438
      sprite(2).width = 292
      end
      I'm doing this for something like a portfolio. You can roll over images and they get larger, but when you roll off of them, they get smaller. I just want them to get smaller over time, and not immediately. Any help would be great. Thanks.
      ~Quadpolar
        • 1. Re: Animated Height and Width
          Level 7
          Since mouseLeave only happens once it can't easily be used to animate
          something... so, you need to set up a system where the shrinking happens
          on an event that happens more often (like enterFrame)

          property pShrink

          on beginSprite me
          pShrink=0 --set it to not shrink when it starts up
          end

          on mouseLeave me
          pShrink=1 --start shrinking now
          end

          on enterFrame me
          if pShrink=1 then
          if sprite(2).height>400 then
          sprite(2).height=sprite(2).height-2
          sprite(2).width=sprite(2).width-2
          else
          pShrink=0 --now it will stop shrinking
          end if
          end if
          end


          This script kind of assumes that the sprite is square, since it adjusts
          the height and width evenly. Change those lines where the width and
          height are lowered by 2 to a greater number to make it go faster or a
          lower number to make it go slower (it has to be an integer, so 1 is as
          slow as it gets). Also, if the height and width are not equal, then
          adjust those same numbers accordingly. I also chose the number 400
          fairly arbitrarily.. that should be whatever height the sprite should be
          when you want it to stop shrinking.
          • 2. Re: Animated Height and Width
            quadpolar Level 1
            Okay, Mike, that worked. I just made a couple of tweaks to it, and it worked perfect. However, here's the second part of this. Behind those images is a "block" of color. Basically what that does is once you roll over a certain area, the block of color will highlight, letting you know there are a "group" of images that are related.

            Here's the problem. That block of color is behind the images, but it surrounds the "group" of images and extends out a few pixels, so it ecompasses them. However, when I roll from the "block" to the actual image, the "block" disappears, because it's not recognizing the mouse is still within it's bounding edges. Simply because the cursor is on an image that is "above" the "block". Here's my script.

            on mouseEnter me
            sprite(4).blend = 50
            end

            on mouseLeave me
            sprite(4).blend = 0
            end

            I feel like this should be so simple, and it is. But I'm not doing something right.
            Thanks.
            ~quadpolar
            • 3. Re: Animated Height and Width
              Level 7
              > Change those lines where the width and
              > height are lowered by 2 to a greater number to make it go faster or a
              > lower number to make it go slower (it has to be an integer, so 1 is as
              > slow as it gets).

              Actually, this is not entirely true. You can use a non-integer value for
              height and width, but when displayed it is rounded to an integer. To test
              this, try having it adjust by 0.5 every frame. What will happen is that it
              will adjust by 1 pixel every other frame. If you adjust by 0.1 every frame,
              it will adjust 1 pixel every 10 frames. So it is possible to get a slower
              than 1-pixel/frame change, just it obviously can't visibly move any slower,
              due basically to the hardware limitation of the display. (Since nothing can
              be drawn smaller than a pixel.)


              • 4. Re: Animated Height and Width
                Level 7
                Put that same code to change the blend of the background sprite on the
                "group" of images. So, the blend is set on mouseEnter of the background
                sprite and each sprite in the "group". Then, regardless of which one it
                is entering, it will still show up