调用事件
1 package
2 {
3 import flash.display.Sprite;
4 import flash.events.Event;
5 import flash.events.EventDispatcher;
6
7 public class people extends Sprite
8 {
9 public var eatEvent:EatEvent;//定义一个“吃饭”的事件
10 private var patch:EventDispatcher;
11 public function people()
12 {
13 this.addEventListener(EatEvent.EAT,eatHalder);
14 eatEvent = new EatEvent(EatEvent.EAT);//创建事件对象
15 dispatchEvent(eatEvent);//发送
16 }
17 private function eatHalder(e:Event):void
18 {
19 trace("知道了,马上就来了!");
20 }
21 }
22 }