3 Replies Latest reply on Dec 8, 2006 5:44 AM by DavidWhewell

    How to force the width of a Sprite

    DavidWhewell Level 1
      Hi there,

      I am writing a display object, which consists of a Sprite containing a TextField. I'm doing it this way because I want to force the text to be positioned within a fixed, larger, coloured area, and sometimes left-aligned within that space, and other times right-aligned within that space. I need to do this as I need the colour of the background to be controllable to reflect state of the items (the textFields update dynamically).

      So I have a Sprite with an opaqueBackground property I can play with, which also contains a TextField with the text. But currently, the Sprite is of course defaulting to the size of its contents, ie the TextField, and I want to be able to specify an arbitrary width, eg sprite.width = 200, where the position of the TextField within the Sprite stays constant, but any extra space within the Sprite is just filled with the background colour. But right now the Sprite is not following .width commands properly. Is there any way I can force this behaviour, or otherwise hack it? I tried using a Shape to generate the background but that lead to lots of very weird problems with the width expanding while trying to fill it.

      I am writing a pure Actionscript 3.0 project, without any Flex elements, so please bear that in mind :)

      Thanks in advance,