Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am having difficulties creating a button that has Dynamic text in it for my interactive quiz game.

The text on the button has to change to show a selectable answer based off of what the current question is.

I have this all working well with plain dynamic text fields (and multidimensional arrays) but when I try getting it to work in a button, flash doesn't recognize the textfield that I placed in the button and I get an error.

After doing some googleing I learned that it is normal for flash to not link to a textfield within a button movieclip.

I would be happy if there any strategies that you could suggest for me to achieve Dynamic Text Buttons.

Thanks! Graeme

share|improve this question
up vote 0 down vote accepted

Just use a MovieClip instead of a button. You can still draw your button-states as different frames on the timeline and use ActionScript to trigger the correct behavior. You could even write a new base-class for your buttons that you can then apply to all your buttons.

Here's how such a class ( could look like:

package  {
    import flash.display.MovieClip;

     * Simulate button behavior with a MovieClip.
     * This assumes:
     * - normal state on frame 1
     * - rollover on frame 2 
     * - active on frame 3
    public class McButton extends MovieClip {

        public function McButton() 
            mouseChildren = false;
            useHandCursor = buttonMode = true;

            addEventListener(MouseEvent.ROLL_OVER, handleMouse, false, 0, true);
            addEventListener(MouseEvent.ROLL_OUT, handleMouse, false, 0, true);
            addEventListener(MouseEvent.MOUSE_DOWN, handleMouse, false, 0, true);
            addEventListener(MouseEvent.MOUSE_UP, handleMouse, false, 0, true);


        private function handleMouse(evt:MouseEvent):void
                case MouseEvent.MOUSE_UP:
                case MouseEvent.ROLL_OVER:

                case MouseEvent.ROLL_OUT:

                case MouseEvent.MOUSE_DOWN:

Then you just create your buttons as MovieClips in the Library and assign the McButton as their base-class (instead of flash.display.MovieClip), as seen in the following screenshot:

flash base class settings

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.