我制作了一个门/按钮并添加为一个类,我想要它,所以当您单击它时,它会调度一个事件,该事件指示主动作脚本页面中的函数运行
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Door extends MovieClip {
var direct:String;
var doorId:int;
var dispatcher = new EventDispatcher();
public function Door() {
this.addEventListener(MouseEvent.CLICK, changeRoom)
this.buttonMode = true;
}
function changeRoom(e:MouseEvent):void{
trace("door click")
dispatcher.dispatchEvent( new Event("doorClick") );
}
}
}
主页看起来像这样
var doorTop = new Door();
doorTop.addEventListener("doorClick",goToRoom);
//should i be doing stage.addEventListener("doorClick",goToRoom);
function goToRoom(e:Event):void
{
trace("i went here")
}
我究竟做错了什么?似乎很直接