2 Replies Latest reply on Aug 16, 2006 2:48 PM by Newsgroup_User

    Resizing Text Field Through Actionscript

    Level 7
      I have seen and read dozens of posts regarding this issue, but do not see
      any that answer my specific question about resizing a dynamically populated
      textfield in flash.

      I have a base MovieClip that will be used to make the buttons of a
      navigation menu. I have a class that defined that movie clip and defines
      things like the label, size of the button and event handlers like onRelease.

      The base MovieClip I used is pretty basic. It has two MovieClips inside it
      with instance names
      bg_mc and
      label_mc.

      Based on one of the parameters passed to the NavButton class the button will
      be resized (_x only). Likewise I would like the text field to center in the
      button. I have been able to accomplish the centering of the label_mc on
      bg_mc once the bg_mc MovieClip has been resized by using:
      label_mc._x = (bg_mc._width - label_mc._width) / 2;

      In the base MovieClip both bg_mc and label_mc have a width of 150, so if I
      create a button with a width of 100 then the formula would look like:
      label_mc._x = (100 - 150) / 2;
      which would be -25.

      An visual example is viewable here
      http://seanberry.com/resizeText.png

      The problem is that the label_mc hanging off the ends will trigger all of
      the events of the button since it is part of the button. The buttons are
      all 2 px apart so the extra part of label_mc will overlap the button to its
      left (since the buttons are placed on the stage from left to right
      increasing in the depth value)

      SO, how do I resize the textbox within label_mc so that there is no
      overhang???

      Thanks for any help.


        • 1. Re: Resizing Text Field Through Actionscript
          blemmo Level 1
          Check out the hitArea property of the MovieClip class. You could use the bg_mc as the hitArea of your buttons, so the overlapping MC shouldn't trigger the events.

          hth,
          blemmo
          • 2. Re: Resizing Text Field Through Actionscript
            Level 7

            "blemmo" <webforumsuser@macromedia.com> wrote in message
            news:ec02hs$t4m$1@forums.macromedia.com...
            > Check out the hitArea property of the MovieClip class. You could use the
            > bg_mc as the hitArea of your buttons, so the overlapping MC shouldn't
            > trigger the events.
            >

            Thanks for the reply.

            I thought about this solution and may have to use it. Is there no way to
            change the size of the textbox dynamically without text distortion?

            I have even noticed before when sizing a textfield on the stage, if the
            handles are used after there is text in the field then it works fine. But,
            if I use the information API to specify the height and width (H: and W:)
            then the text will distort.