1
2 package org.freehep.graphicsio.swf;
3
4 import java.io.IOException;
5 import java.util.Vector;
6
7
8
9
10
11
12
13
14 public class ClipActionRecord {
15
16 private ClipEventFlags eventFlags;
17
18 private long actionRecordSize;
19
20 private int keyCode;
21
22 private Vector actions;
23
24
25
26
27 public ClipActionRecord(SWFInputStream swf) throws IOException {
28
29 eventFlags = new ClipEventFlags(swf);
30 if (eventFlags.isEndFlag())
31 return;
32
33 actionRecordSize = swf.readUnsignedInt();
34
35 swf.pushBuffer((int) (actionRecordSize - 4));
36 if (eventFlags.isKeyPress())
37 keyCode = swf.readUnsignedByte();
38
39 while (swf.getLength() > 0) {
40 actions.add(swf.readAction());
41 }
42 byte[] rest = swf.popBuffer();
43 if (rest != null) {
44 System.err.println("Corrupted ClipActionRecord, " + rest.length
45 + " bytes leftoever.");
46 }
47 }
48
49 public void write(SWFOutputStream swf) throws IOException {
50 eventFlags.write(swf);
51
52 swf.writeUnsignedInt(actionRecordSize);
53 if (eventFlags.isKeyPress())
54 swf.writeUnsignedByte(keyCode);
55
56 for (int i = 0; i < actions.size(); i++) {
57 SWFAction a = (SWFAction) actions.get(i);
58 swf.writeAction(a);
59 }
60 }
61
62 public boolean isEndRecord() {
63 return eventFlags.isEndFlag();
64 }
65
66 public String toString() {
67 return "ClipActionRecord " + actions.size();
68 }
69 }