这款游戏是一款棋盘游戏,因此需要传递信息,但大部分都不是动态的。
这是自定义事件的正确定义吗?
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");
}
}
}
如果是这样,为什么这段代码会离开 事件属性未定义?
导入集; import 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();
}
}
答案 0 :(得分:0)
尝试将排除参数更改为设置
private function Exclusion(e:Set):void {
}