ActionScript 3.0: myClass extends Button not working

88 Views Asked by At

I am newbie to Actionscript 3.0 so any help will be greatly appreciated. I am trying to get into AS3 and class definitions, so I created a myButtonClass extends Button to build buttons dynamically. However, when the button appears on the SWF it cant be clicked, looks like inactive, with no animation at all. I know that I can extend myClass with MovieClip and do all the respective scripting, but I want to understand why it is not working the way I am doing it. Moreover, to make it work I had to add the built-in button to my Library so the needed parts to build the button can be used by the compiler. Here's the script:

package code {

    import fl.controls.Button;
    import flash.events.MouseEvent;

    public class Boton extends Button {

        public function Boton() {
            setupBoton("My button");
        }

        function setupBoton(texto: String): void {
            super.label = texto;
            super.x = 400;
            super.y = 100;
            super.width = 100;
            super.height = 25;
            super.enabled = true;
            this.addEventListener(MouseEvent.CLICK, changeLabel);


        }
        function changeLabel(event: MouseEvent): void {

            super.label = "Label changed";

        }

    }

}

What am I missing???

sincerely,

Lorenzo

0

There are 0 best solutions below