【发布时间】:2017-10-21 20:39:40
【问题描述】:
我有两个班级,我尝试了从一个班级到另一个班级的事件调度。在这里,我使用按钮来调用该类。但是调度不起作用。
class name cusDispatcher.as
package
{
import flash.display.MovieClip;
import flash.events.EventDispatcher;
import flash.events.Event;
import flash.events.MouseEvent;
import Globe;
public class CusDispatcher extends EventDispatcher
{
public function CusDispatcher():void
{
Globe.self.realstage.btn_mc.addEventListener(MouseEvent.CLICK,
doAction);
}
public function doAction(event:MouseEvent):void
{
dispatchEvent(new Event('myevent'));
}
}
}
类名 EventDispatcherExample.as 包裹 {
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.EventDispatcher;
import Globe;
public class EventDispatcherExample extends EventDispatcher
{
public function EventDispatcherExample(Mc:MovieClip)
{
Globe.self.realstage = Mc;
var start:CusDispatcher = new CusDispatcher();
Globe.self.realstage.addEventListener('myevent', handler);
trace("one");
}
public function handler(event:Event):void
{
trace("My Event");
}
}
}
在 adobe CC 中我使用这个实例来运行类
var Call:EventDispatcherExample = new EventDispatcherExample(this);
每当我单击 adobe flash cc 中的按钮 (btn_mc) 时,它都不会显示任何 跟踪调度事件。所以请对此进行分析并给出解决方案。
【问题讨论】:
-
因为 Globe.self.realstage 不调度 myevent 事件。
标签: actionscript-3 flash actionscript flex3