views:

882

answers:

1

Hi, I want to make a simple tab menu in flash dynamically and I want only the very first tab to be enabled in the beginning of work with my app - the others will be enabled later. However, after exporting the movie, tabs arent clickable (cursor does not appear as hand), but when I click on one of them, its code is launched. Where may be the problem? This is my code (I have only two tabs so far):

var shieldTab = new Tab("Shield", "shieldMenu", 590,120);
this.addChild(shieldTab);
mainMenu.push(shieldTab);
var orderTab = new Tab("Order", "orderMenu", 590+shieldTab.width, 120);
this.addChild(orderTab);
mainMenu.push(orderTab);

for each (var tab:SimpleButton in mainMenu){
    tab.addEventListener(MouseEvent.CLICK, showMenu);
}

this.orderTab.enabled = false;

and this is Tab class:

package coa.application{
    import flash.display.SimpleButton;
    import flash.text.*;

    public class Tab extends SimpleButton {

     public var menuType:String;

     public function Tab(tabText:String, menuType:String, x:Number, y:Number) {
      this.menuType=menuType;
      var mytext:TextField=new TextField();
      var fm:TextFormat = new TextFormat("Verdana", 18);
      mytext.autoSize = TextFieldAutoSize.CENTER;
      mytext.text=tabText;
      mytext.border = true;
      mytext.selectable = false;
      mytext.background = true;
      mytext.setTextFormat(fm);
      upState = overState = downState = hitTestState = mytext;
      this.x=x;
      this.y=y;

     }
    }
}
+1  A: 

I don't think there's an "enabled" property. Have you tried just mouseEnabled to false. Or even better. Make an enabled property on you tab class, and then check that in showMenu. Then you can just ignore the click if the tab is not enabled.

Lillemanden
thanx, the mouseEnabled property solved my problem ;)
Dungeo