4 Replies Latest reply on Jun 11, 2006 7:11 AM by NSurveyor

    Dynamic Border around image

    Level 7
      hi there,
      i have a main flash movie (main.fla) which has images placed on the screen.
      Each image has an invisible button placed on it.. (ie: the button has only
      the hitarea defined and no rollover, down etc.)

      NOTE: that the images are different in sizes. hence they have different
      width and height.

      I tried making a movieclip of 200 x 200 in size with a 1px border around it
      and dynamically making it adjust to the width and height of the images. BUT
      i seem to be hacing the following problem-
      1) for images that are larger in size than the border movieclip.. the border
      tends to thicken.
      2) for images that are smaller than the border movieclip.. the border tends
      to get more thinner


      Required-
      OnRollover of an image.. it should have a border around it, inorder to
      highlite the selected image. Lets say, a 1px border and red in color. How do
      i achieve this?

      Would really appreciate if someone would provide a simple code to achieve
      this as i am not used to programming.

      Please help..

      thanx



        • 1. Re: Dynamic Border around image
          neil manuell Level 1
          yep, thats cause when you stretch your mc the lines will stretch with it.

          if you are using flash 8, use the 9slice guides.

          for the mc that contains your border go into the preferances, and you will find a check box for the 9slice thingy (technical term)
          check that, then double click on the library symbel to edit it.
          you will find flash has drawn four dashed lines.
          move these so that they mark the inward edge of your borders.
          basically the area inside these guides stretches normally
          the corners don't stretch
          and the edges stretch either horizonally or vertically

          for more info look in the help.

          oh, and don't transform (rotate skew etc) your mc once on the stage or you'll loose your slices...

          best
          • 2. Re: Dynamic Border around image
            Jim_Esteban Level 1
            I could be wrong about this but can't you draw the border for the image after you have scaled it in the Listener.onLoadInit event function and then redraw it with a different line style(ie color) in the onRollover event.
            • 3. Re: Dynamic Border around image
              NSurveyor Level 2
              If you have Flash 8, select your line and open up the Properties Panel. Then, select "none" for Scale.

              You can achieve this through ActionScript. Say you have a MovieClip, called clip, with an image inside it. You could use this code:
              • 4. Re: Dynamic Border around image
                NSurveyor Level 2
                I just realized a really stupid mistake in the above code.... it should say with(this) and and getBounds(this). I also made it work on clips with distorted dimensions So, here is the corrected code: