Merge pull request #170 from nathan/menu-lines

Fixed variables named "---" not appearing in menus
This commit is contained in:
Shane M. Clements 2014-06-03 10:05:46 -06:00
commit 64b4df3968
2 changed files with 6 additions and 5 deletions

View file

@ -44,6 +44,7 @@ public class Menu extends Sprite {
public var minWidth:int;
public var itemHeight:int;
public static var line:Object = new Object;
private static var menuJustCreated:Boolean;
private var menuName:String = '';
@ -61,7 +62,7 @@ public class Menu extends Sprite {
this.itemHeight = itemHeight;
}
public function addItem(label:String, value:* = null, enabled:Boolean = true, checkmark:Boolean = false):void {
public function addItem(label:*, value:* = null, enabled:Boolean = true, checkmark:Boolean = false):void {
var last:MenuItem = allItems.length ? allItems[allItems.length-1] : null;
var newItem:MenuItem = new MenuItem(this, label, value, enabled);
if ((!last || last.isLine()) && newItem.isLine()) return;
@ -70,7 +71,7 @@ public class Menu extends Sprite {
}
public function addLine():void {
addItem('---');
addItem(line);
}
public function showOnStage(stage:Stage, x:int = -1, y:int = -1):void {

View file

@ -44,13 +44,13 @@ public class MenuItem extends Sprite {
private var base:Shape;
private var w:int, h:int;
public function MenuItem(menu:Menu, labelText:String, selection:*, enabled:Boolean) {
public function MenuItem(menu:Menu, labelText:*, selection:*, enabled:Boolean) {
this.menu = menu;
this.selection = (selection == null) ? labelText : selection;
addChild(base = new Shape());
if (labelText == '---') return;
if (labelText == Menu.line) return;
addCheckmark();
addLabel(labelText, enabled);
addLabel(String(labelText), enabled);
setBaseColor(menu.color);
if (enabled) {
addEventListener(MouseEvent.MOUSE_OVER, mouseOver);