不要让代码写在帧上
不要让代码写在帧上
1 static public const FRAME_ROOM:String = "room";
2 static public const FRAME_LAWN:String = "lawn";
3
4 public function Main () {
5 stop();
6
7 enumerateFrameLabels();
8 addEventListener(FRAME_ROOM, setupROOM);
9 addEventListener(FRAME_LAWN, setupLAWN);
10 }
11
12 private function setupLAWN(e:Event):void {
13
14 }
15
16 private function setupROOM(e:Event):void {
17
18 }
19
20 private function enumerateFrameLabels() {
21 for each (var label:FrameLabel in currentLabels)
22 addFrameScript(label.frame-1, dispatchFrameEvent);
23 }
24
25 private function dispatchFrameEvent() {
26 dispatchEvent(new Event(currentLabel));
27 }