OSDN Git Service

add ui16be method
[flapp/flapp.git] / src / action.js
1 goog.provide('FlappAction');
2 goog.require('FlappIBit');
3
4 goog.scope(function() {
5
6 /**
7  * @constructor
8  */
9 FlappAction = function() {
10     this.actionRecord = null;
11 };
12
13 FlappAction.exec = function(tag, movieClip, rootMovieClip) {
14     console.debug("FlappAction.exec");
15     var actionsBit = new FlappIBit();
16     actionsBit.input(tag.actions);
17     var code = 0;
18     var stack = [];
19     while (code = actionsBit.ui8()) {
20         if (code < 0x80) {
21             switch (code) {
22             case 0x06: // Play
23                 movieClip.play();
24                 break;
25             case 0x07: // Stop
26                 movieClip.stop();
27                 break;
28             case 0x1d: // SetVariables
29                 movieClip.setVariable(stack.pop(), stack.pop());
30                 break;
31             default:
32                 console.debug("FlappActiom: not implemented yet. code=0x%02x", code);
33                 break;
34             }
35         } else {
36             var actionLength = actionsBit.input(tag.actions);
37             var nextActionOffset = actionsBit.getBytePos() + actionLength;
38             switch (code) {
39             case 0x81: // GotoFrame
40                 movieClip.gotoFrame(actionsBit.si16());
41                 break;
42             case 0x83: // GetURL
43                 //
44                 break;
45             case 0x8c: // GoToLabel
46                 movieClip.gotoLabel(actionsBit.strN(actionLength));
47                 break;
48                 //case 0x96: // Push
49             default:
50                 console.debug("FlappActiom: not implemented yet. code=0x%02x", code);
51                 break;
52             }
53             actionsBit.setPos(nextActionOffset, 0);
54         }
55     }
56 };
57
58 });