0

这个游戏是一个棋盘游戏,所以它需要传递信息,但大多不是动态的。

这是自定义事件的正确定义吗?

package
{
    import flash.events.Event;

    public class Set extends Event
    {
        public var addsub:Boolean;
        public var kanaex:String; 
        public var valueex:uint;
        public var xx:uint;
        public var yy:uint;

        public static const BOARD_SET_CHANGED:String = "BoardSetChanged";
        public static const BOX_SET_CHANGED:String = "BoxSetChanged";

        public function Set(type:String, addsub1:Boolean, kanaex1:String, valueex1:uint, xx1:uint,yy1:uint,   bubbles:Boolean = false, cancelable:Boolean = false)
        {
            super(type, bubbles, cancelable);
            addsub = addsub1;
            kanaex = kanaex1;
            valueex= valueex1;
            xx = xx1;
            yy = yy1; 
        }

        override public function clone():Event
        {
            return new Set(type, addsub, kanaex,valueex,xx,yy, bubbles, cancelable );
        }

        override public function toString():String
        {
            return formatToString("BoardSetChanged","addsub","kanaex","valueex","xx","yy","bubbles", "cancelable");
        }
    }
}

如果是这样,为什么此代码未定义事件属性?

导入集;导入 flash.events.*;

   this.addEventListener(Set.BOARD_SET_CHANGED, Exclusion);
private function Exclusion(e:Event)
            {
                var a:Boolean = e.addsub;
                var b:uint = e.xx;
                var c:uint = e.yy;
                if (a == true)
                {exclusionx.push(b);
                exclusiony.push(c); 
                }
                else if (a == false)
                {exclusionx.pop();
                 exclusiony.pop(); 
                    }
            }
4

1 回答 1

0

尝试将Exclusion的参数更改为Set

private function Exclusion(e:Set):void {




}
于 2013-09-19T02:10:24.160 回答