自定义事件应该有 get 方法吗?
Should a custom event have get methods?
我在桌面应用程序中创建了一些自定义事件,并为其提供了一些获取方法以获取与该事件关联的数据。在事件上调用 'get' 方法似乎很奇怪。这是糟糕的编程习惯吗,我应该改用事件属性 public 吗?
这是我的自定义事件...
package classes.events
{
import flash.events.Event;
public class ListItemClickedEvent extends Event
{
public static var PROJECT_CHOSEN:String = "project_chosen";
private var projectName:String;
private var projectLabel:String;
private var projectFolder:String;
public function ListItemClickedEvent(type:String, bubbles:Boolean = true,
cancelable:Boolean = false, pName:String = null,
pLabel:String = null, pFolder:String = null){
super(type, bubbles, cancelable);
projectName = pName;
projectLabel = pLabel;
projectFolder = pFolder;
}
override public function clone():Event{
return new ListItemClickedEvent(type, bubbles, cancelable);
}
public function getProjectName():String{
return projectName;
}
public function getProjectLabel():String{
return projectLabel;
}
public function getProjectFolder():String{
return projectFolder;
}
}
}
我在桌面应用程序中创建了一些自定义事件,并为其提供了一些获取方法以获取与该事件关联的数据。在事件上调用 'get' 方法似乎很奇怪。这是糟糕的编程习惯吗,我应该改用事件属性 public 吗?
这是我的自定义事件...
package classes.events
{
import flash.events.Event;
public class ListItemClickedEvent extends Event
{
public static var PROJECT_CHOSEN:String = "project_chosen";
private var projectName:String;
private var projectLabel:String;
private var projectFolder:String;
public function ListItemClickedEvent(type:String, bubbles:Boolean = true,
cancelable:Boolean = false, pName:String = null,
pLabel:String = null, pFolder:String = null){
super(type, bubbles, cancelable);
projectName = pName;
projectLabel = pLabel;
projectFolder = pFolder;
}
override public function clone():Event{
return new ListItemClickedEvent(type, bubbles, cancelable);
}
public function getProjectName():String{
return projectName;
}
public function getProjectLabel():String{
return projectLabel;
}
public function getProjectFolder():String{
return projectFolder;
}
}
}