| 1 |
|
| 2 |
package org.freehep.graphicsio.swf; |
| 3 |
|
| 4 |
import java.io.EOFException; |
| 5 |
import java.io.IOException; |
| 6 |
import java.util.Vector; |
| 7 |
|
| 8 |
import org.freehep.util.io.Action; |
| 9 |
import org.freehep.util.io.TaggedInputStream; |
| 10 |
import org.freehep.util.io.TaggedOutputStream; |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
public abstract class SWFAction extends Action { |
| 20 |
|
| 21 |
private int version; |
| 22 |
|
| 23 |
protected SWFAction(int code, int version) { |
| 24 |
super(code); |
| 25 |
this.version = version; |
| 26 |
} |
| 27 |
|
| 28 |
public int getVersion() { |
| 29 |
return version; |
| 30 |
} |
| 31 |
|
| 32 |
public Action read(int actionCode, TaggedInputStream input, int length) |
| 33 |
throws IOException { |
| 34 |
|
| 35 |
return read(actionCode, (SWFInputStream) input, length); |
| 36 |
} |
| 37 |
|
| 38 |
public SWFAction read(int actionCode, SWFInputStream swf, int length) |
| 39 |
throws IOException { |
| 40 |
|
| 41 |
return this; |
| 42 |
} |
| 43 |
|
| 44 |
public void write(int actionCode, TaggedOutputStream input) |
| 45 |
throws IOException { |
| 46 |
|
| 47 |
write(actionCode, (SWFOutputStream) input); |
| 48 |
} |
| 49 |
|
| 50 |
public void write(int actionCode, SWFOutputStream swf) throws IOException { |
| 51 |
|
| 52 |
|
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
public static class GotoFrame extends SWFAction { |
| 59 |
private int frame; |
| 60 |
|
| 61 |
public GotoFrame(int frame) { |
| 62 |
this(); |
| 63 |
this.frame = frame; |
| 64 |
} |
| 65 |
|
| 66 |
public GotoFrame() { |
| 67 |
super(0x81, 3); |
| 68 |
} |
| 69 |
|
| 70 |
public SWFAction read(int actionCode, SWFInputStream swf, int length) |
| 71 |
throws IOException { |
| 72 |
|
| 73 |
GotoFrame action = new GotoFrame(); |
| 74 |
action.frame = swf.readUnsignedShort(); |
| 75 |
return action; |
| 76 |
} |
| 77 |
|
| 78 |
public void write(int actionCode, SWFOutputStream swf) |
| 79 |
throws IOException { |
| 80 |
|
| 81 |
swf.writeUnsignedShort(frame); |
| 82 |
} |
| 83 |
|
| 84 |
public String toString() { |
| 85 |
return super.toString() + ", frame " + frame; |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
public static class GetURL extends SWFAction { |
| 93 |
private String url; |
| 94 |
|
| 95 |
private String window; |
| 96 |
|
| 97 |
public GetURL(String url, String window) { |
| 98 |
this(); |
| 99 |
this.url = url; |
| 100 |
this.window = window; |
| 101 |
} |
| 102 |
|
| 103 |
public GetURL() { |
| 104 |
super(0x83, 3); |
| 105 |
} |
| 106 |
|
| 107 |
public SWFAction read(int actionCode, SWFInputStream swf, int length) |
| 108 |
throws IOException { |
| 109 |
|
| 110 |
GetURL action = new GetURL(); |
| 111 |
action.url = swf.readString(); |
| 112 |
action.window = swf.readString(); |
| 113 |
return action; |
| 114 |
} |
| 115 |
|
| 116 |
public void write(int actionCode, SWFOutputStream swf) |
| 117 |
throws IOException { |
| 118 |
|
| 119 |
swf.writeString(url); |
| 120 |
swf.writeString(window); |
| 121 |
} |
| 122 |
|
| 123 |
public String toString() { |
| 124 |
return super.toString() + ", URL " + url + ", window " + window; |
| 125 |
} |
| 126 |
} |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
public static class NextFrame extends SWFAction { |
| 133 |
public NextFrame() { |
| 134 |
super(0x04, 3); |
| 135 |
} |
| 136 |
} |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
public static class PreviousFrame extends SWFAction { |
| 142 |
public PreviousFrame() { |
| 143 |
super(0x05, 3); |
| 144 |
} |
| 145 |
} |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
public static class Play extends SWFAction { |
| 151 |
public Play() { |
| 152 |
super(0x06, 3); |
| 153 |
} |
| 154 |
} |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
public static class Stop extends SWFAction { |
| 160 |
public Stop() { |
| 161 |
super(0x07, 3); |
| 162 |
} |
| 163 |
} |
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
public static class ToggleQuality extends SWFAction { |
| 169 |
public ToggleQuality() { |
| 170 |
super(0x08, 3); |
| 171 |
} |
| 172 |
} |
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
public static class StopSounds extends SWFAction { |
| 178 |
public StopSounds() { |
| 179 |
super(0x09, 3); |
| 180 |
} |
| 181 |
} |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
public static class WaitForFrame extends SWFAction { |
| 187 |
private int frame; |
| 188 |
|
| 189 |
private int skip; |
| 190 |
|
| 191 |
public WaitForFrame(int frame, int skip) { |
| 192 |
this(); |
| 193 |
this.frame = frame; |
| 194 |
this.skip = skip; |
| 195 |
} |
| 196 |
|
| 197 |
public WaitForFrame() { |
| 198 |
super(0x8a, 3); |
| 199 |
} |
| 200 |
|
| 201 |
public SWFAction read(int actionCode, SWFInputStream swf, int length) |
| 202 |
throws IOException { |
| 203 |
|
| 204 |
WaitForFrame action = new WaitForFrame(); |
| 205 |
action.frame = swf.readUnsignedShort(); |
| 206 |
action.skip = swf.readUnsignedByte(); |
| 207 |
return action; |
| 208 |
} |
| 209 |
|
| 210 |
public void write(int actionCode, SWFOutputStream swf) |
| 211 |
throws IOException { |
| 212 |
|
| 213 |
swf.writeUnsignedShort(frame); |
| 214 |
swf.writeUnsignedByte(skip); |
| 215 |
} |
| 216 |
|
| 217 |
public String toString() { |
| 218 |
return super.toString() + ", frame " + frame + ", skip " + skip; |
| 219 |
} |
| 220 |
} |
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
public static class SetTarget extends SWFAction { |
| 226 |
private String target; |
| 227 |
|
| 228 |
public SetTarget(String target) { |
| 229 |
this(); |
| 230 |
this.target = target; |
| 231 |
} |
| 232 |
|
| 233 |
public SetTarget() { |
| 234 |
super(0x8b, 3); |
| 235 |
} |
| 236 |
|
| 237 |
public SWFAction read(int actionCode, SWFInputStream swf, int length) |
| 238 |
throws IOException { |
| 239 |
|
| 240 |
SetTarget action = new SetTarget(); |
| 241 |
action.target = swf.readString(); |
| 242 |
return action; |
| 243 |
} |
| 244 |
|
| 245 |
public void write(int actionCode, SWFOutputStream swf) |
| 246 |
throws IOException { |
| 247 |
|
| 248 |
swf.writeString(target); |
| 249 |
} |
| 250 |
|
| 251 |
public String toString() { |
| 252 |
return super.toString() + ", target " + target; |
| 253 |
} |
| 254 |
} |
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
public static class GotoLabel extends SWFAction { |
| 260 |
private String label; |
| 261 |
|
| 262 |
public GotoLabel(String label) { |
| 263 |
this(); |
| 264 |
this.label = label; |
| 265 |
} |
| 266 |
|
| 267 |
public GotoLabel() { |
| 268 |
super(0x8c, 3); |
| 269 |
} |
| 270 |
|
| 271 |
public SWFAction read(int actionCode, SWFInputStream swf, int length) |
| 272 |
throws IOException { |
| 273 |
|
| 274 |
GotoLabel action = new GotoLabel(); |
| 275 |
action.label = swf.readString(); |
| 276 |
return action; |
| 277 |
} |
| 278 |
|
| 279 |
public void write(int actionCode, SWFOutputStream swf) |
| 280 |
throws IOException { |
| 281 |
|
| 282 |
swf.writeString(label); |
| 283 |
} |
| 284 |
|
| 285 |
public String toString() { |
| 286 |
return super.toString() + ", label " + label; |
| 287 |
} |
| 288 |
} |
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
public static class Add extends SWFAction { |
| 295 |
public Add() { |
| 296 |
super(0x0a, 4); |
| 297 |
} |
| 298 |
} |
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
public static class Subtract extends SWFAction { |
| 304 |
public Subtract() { |
| 305 |
super(0x0b, 4); |
| 306 |
} |
| 307 |
} |
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
public static class Multiply extends SWFAction { |
| 313 |
public Multiply() { |
| 314 |
super(0x0c, 4); |
| 315 |
} |
| 316 |
} |
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
public static class Divide extends SWFAction { |
| 322 |
public Divide() { |
| 323 |
super(0x0d, 4); |
| 324 |
} |
| 325 |
} |
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
public static class WaitForFrame2 extends SWFAction { |
| 331 |
private int skip; |
| 332 |
|
| 333 |
public WaitForFrame2(int skip) { |
| 334 |
this(); |
| 335 |
this.skip = skip; |
| 336 |
} |
| 337 |
|
| 338 |
public WaitForFrame2() { |
| 339 |
super(0x8D, 4); |
| 340 |
} |
| 341 |
|
| 342 |
public SWFAction read(int actionCode, SWFInputStream swf, int length) |
| 343 |
throws IOException { |
| 344 |
|
| 345 |
WaitForFrame2 action = new WaitForFrame2(); |
| 346 |
action.skip = swf.readUnsignedByte(); |
| 347 |
return action; |
| 348 |
} |
| 349 |
|
| 350 |
public void write(int actionCode, SWFOutputStream swf) |
| 351 |
throws IOException { |
| 352 |
|
| 353 |
swf.writeUnsignedByte(skip); |
| 354 |
} |
| 355 |
|
| 356 |
public String toString() { |
| 357 |
return super.toString() + ", skipCount:" + skip; |
| 358 |
} |
| 359 |
} |
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
public static class Equals extends SWFAction { |
| 365 |
public Equals() { |
| 366 |
super(0x0e, 4); |
| 367 |
} |
| 368 |
} |
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
public static class Less extends SWFAction { |
| 374 |
public Less() { |
| 375 |
super(0x0f, 4); |
| 376 |
} |
| 377 |
} |
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
public static class And extends SWFAction { |
| 383 |
public And() { |
| 384 |
super(0x10, 4); |
| 385 |
} |
| 386 |
} |
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
public static class Or extends SWFAction { |
| 392 |
public Or() { |
| 393 |
super(0x11, 4); |
| 394 |
} |
| 395 |
} |
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
public static class Not extends SWFAction { |
| 401 |
public Not() { |
| 402 |
super(0x12, 4); |
| 403 |
} |
| 404 |
} |
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
public static class StringEquals extends SWFAction { |
| 410 |
public StringEquals() { |
| 411 |
super(0x13, 4); |
| 412 |
} |
| 413 |
} |
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
public static class StringLength extends SWFAction { |
| 419 |
public StringLength() { |
| 420 |
super(0x14, 4); |
| 421 |
} |
| 422 |
} |
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
public static class StringExtract extends SWFAction { |
| 428 |
public StringExtract() { |
| 429 |
super(0x15, 4); |
| 430 |
} |
| 431 |
} |
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
public static class Push extends SWFAction { |
| 437 |
public static final int STRING = 0; |
| 438 |
|
| 439 |
public static final int FLOAT = 1; |
| 440 |
|
| 441 |
public static final int NULL = 2; |
| 442 |
|
| 443 |
public static final int UNDEFINED = 3; |
| 444 |
|
| 445 |
public static final int REGISTER = 4; |
| 446 |
|
| 447 |
public static final int BOOLEAN = 5; |
| 448 |
|
| 449 |
public static final int DOUBLE = 6; |
| 450 |
|
| 451 |
public static final int INTEGER = 7; |
| 452 |
|
| 453 |
public static final int LOOKUP = 8; |
| 454 |
|
| 455 |
public static final int LOOKUP2 = 9; |
| 456 |
|
| 457 |
private Vector<Value> values; |
| 458 |
|
| 459 |
public static class Value { |
| 460 |
private byte type; |
| 461 |
|
| 462 |
private Object value; |
| 463 |
|
| 464 |
private byte[] data; |
| 465 |
|
| 466 |
public Value(String s) { |
| 467 |
type = STRING; |
| 468 |
value = s; |
| 469 |
} |
| 470 |
|
| 471 |
public Value(float f) { |
| 472 |
type = FLOAT; |
| 473 |
value = new Float(f); |
| 474 |
} |
| 475 |
|
| 476 |
public Value(Object x) { |
| 477 |
type = NULL; |
| 478 |
value = null; |
| 479 |
} |
| 480 |
|
| 481 |
public Value(byte r) { |
| 482 |
type = REGISTER; |
| 483 |
value = new Byte(r); |
| 484 |
} |
| 485 |
|
| 486 |
public Value(boolean b) { |
| 487 |
type = BOOLEAN; |
| 488 |
value = new Boolean(b); |
| 489 |
} |
| 490 |
|
| 491 |
public Value(double d) { |
| 492 |
type = DOUBLE; |
| 493 |
value = new Double(d); |
| 494 |
} |
| 495 |
|
| 496 |
public Value(int i) { |
| 497 |
type = INTEGER; |
| 498 |
value = new Integer(i); |
| 499 |
} |
| 500 |
|
| 501 |
public Value(short index) { |
| 502 |
type = LOOKUP; |
| 503 |
value = new Short(index); |
| 504 |
} |
| 505 |
|
| 506 |
public Value(byte type, byte[] data) { |
| 507 |
this.type = type; |
| 508 |
this.data = data; |
| 509 |
} |
| 510 |
|
| 511 |
public static Value read(SWFInputStream swf) throws IOException { |
| 512 |
byte type = swf.readByte(); |
| 513 |
switch (type) { |
| 514 |
case STRING: |
| 515 |
return new Value(swf.readString()); |
| 516 |
case FLOAT: |
| 517 |
return new Value(swf.readFloat()); |
| 518 |
case NULL: |
| 519 |
return new Value(null); |
| 520 |
case REGISTER: |
| 521 |
return new Value((byte) swf.readUnsignedByte()); |
| 522 |
case BOOLEAN: |
| 523 |
return new Value((swf.readByte() != 0) ? true : false); |
| 524 |
case DOUBLE: |
| 525 |
return new Value(swf.readDouble()); |
| 526 |
case INTEGER: |
| 527 |
return new Value(swf.readInt()); |
| 528 |
case LOOKUP: |
| 529 |
return new Value((short) swf.readUnsignedByte()); |
| 530 |
case LOOKUP2: |
| 531 |
return new Value((byte) LOOKUP2, swf.readByte(2)); |
| 532 |
default: |
| 533 |
return new Value(type, swf.readByte((int) swf.getLength())); |
| 534 |
} |
| 535 |
} |
| 536 |
|
| 537 |
public void write(SWFOutputStream swf) throws IOException { |
| 538 |
swf.writeByte(type); |
| 539 |
switch (type) { |
| 540 |
case STRING: |
| 541 |
swf.writeString((String) value); |
| 542 |
break; |
| 543 |
case FLOAT: |
| 544 |
swf.writeFloat(((Float) value).floatValue()); |
| 545 |
break; |
| 546 |
case NULL: |
| 547 |
break; |
| 548 |
case UNDEFINED: |
| 549 |
break; |
| 550 |
case REGISTER: |
| 551 |
swf.writeUnsignedByte(((Byte) value).byteValue()); |
| 552 |
break; |
| 553 |
case BOOLEAN: |
| 554 |
swf.writeBoolean(((Boolean) value).booleanValue()); |
| 555 |
break; |
| 556 |
case DOUBLE: |
| 557 |
swf.writeDouble(((Double) value).doubleValue()); |
| 558 |
break; |
| 559 |
case INTEGER: |
| 560 |
swf.writeInt(((Integer) value).intValue()); |
| 561 |
break; |
| 562 |
case LOOKUP: |
| 563 |
swf.writeUnsignedByte(((Short) value).shortValue()); |
| 564 |
break; |
| 565 |
case LOOKUP2: |
| 566 |
swf.writeShort(((Short) value).shortValue()); |
| 567 |
break; |
| 568 |
default: |
| 569 |
swf.writeByte(data); |
| 570 |
break; |
| 571 |
} |
| 572 |
} |
| 573 |
|
| 574 |
public String toString() { |
| 575 |
StringBuffer s = new StringBuffer("PushValue "); |
| 576 |
if ((type < 0) || (type > 9)) { |
| 577 |
s.append("Unknown Data Type " + type + " with length " |
| 578 |
+ data.length); |
| 579 |
} else { |
| 580 |
s.append(value); |
| 581 |
} |
| 582 |
return s.toString(); |
| 583 |
} |
| 584 |
} |
| 585 |
|
| 586 |
public Push() { |
| 587 |
super(0x96, 4); |
| 588 |
} |
| 589 |
|
| 590 |
public SWFAction read(int actionCode, SWFInputStream swf, int length) |
| 591 |
throws IOException { |
| 592 |
|
| 593 |
Push action = new Push(); |
| 594 |
action.values = new Vector<Value>(); |
| 595 |
|
| 596 |
try { |
| 597 |
while (true) { |
| 598 |
action.values.add(Value.read(swf)); |
| 599 |
} |
| 600 |
} catch (EOFException e) { |
| 601 |
} |
| 602 |
return action; |
| 603 |
} |
| 604 |
|
| 605 |
public void write(int actionCode, SWFOutputStream swf) |
| 606 |
throws IOException { |
| 607 |
|
| 608 |
for (int i = 0; i < values.size(); i++) { |
| 609 |
values.get(i).write(swf); |
| 610 |
} |
| 611 |
} |
| 612 |
|
| 613 |
public String toString() { |
| 614 |
StringBuffer s = new StringBuffer(super.toString()); |
| 615 |
s.append("\n"); |
| 616 |
for (int i = 0; i < values.size(); i++) { |
| 617 |
s.append(" "); |
| 618 |
s.append(values.get(i)); |
| 619 |
s.append("\n"); |
| 620 |
} |
| 621 |
return s.toString(); |
| 622 |
} |
| 623 |
} |
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
public static class Pop extends SWFAction { |
| 629 |
public Pop() { |
| 630 |
super(0x17, 4); |
| 631 |
} |
| 632 |
} |
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
public static class ToInteger extends SWFAction { |
| 638 |
public ToInteger() { |
| 639 |
super(0x18, 4); |
| 640 |
} |
| 641 |
} |
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
public static class Jump extends SWFAction { |
| 647 |
private short offset; |
| 648 |
|
| 649 |
public Jump(short offset) { |
| 650 |
this(); |
| 651 |
this.offset = offset; |
| 652 |
} |
| 653 |
|
| 654 |
public Jump() { |
| 655 |
super(0x99, 4); |
| 656 |
} |
| 657 |
|
| 658 |
public SWFAction read(int actionCode, SWFInputStream swf, int length) |
| 659 |
throws IOException { |
| 660 |
|
| 661 |
Jump action = new Jump(); |
| 662 |
action.offset = swf.readShort(); |
| 663 |
return action; |
| 664 |
} |
| 665 |
|
| 666 |
public void write(int actionCode, SWFOutputStream swf) |
| 667 |
throws IOException { |
| 668 |
|
| 669 |
swf.writeShort(offset); |
| 670 |
} |
| 671 |
|
| 672 |
public String toString() { |
| 673 |
return super.toString() + ", " + offset; |
| 674 |
} |
| 675 |
} |
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
public static class GetURL2 extends SWFAction { |
| 681 |
private byte method; |
| 682 |
|
| 683 |
public static final int NONE = 0; |
| 684 |
|
| 685 |
public static final int GET = 1; |
| 686 |
|
| 687 |
public static final int POST = 2; |
| 688 |
|
| 689 |
public GetURL2(byte method) { |
| 690 |
this(); |
| 691 |
this.method = method; |
| 692 |
} |
| 693 |
|
| 694 |
public GetURL2() { |
| 695 |
super(0x9A, 4); |
| 696 |
} |
| 697 |
|
| 698 |
public SWFAction read(int actionCode, SWFInputStream swf, int length) |
| 699 |
throws IOException { |
| 700 |
|
| 701 |
GetURL2 action = new GetURL2(); |
| 702 |
action.method = swf.readByte(); |
| 703 |
return action; |
| 704 |
} |
| 705 |
|
| 706 |
public void write(int actionCode, SWFOutputStream swf) |
| 707 |
throws IOException { |
| 708 |
|
| 709 |
swf.writeByte(method); |
| 710 |
} |
| 711 |
|
| 712 |
public String toString() { |
| 713 |
return super.toString() + ", " + method; |
| 714 |
} |
| 715 |
} |
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
public static class GetVariable extends SWFAction { |
| 721 |
public GetVariable() { |
| 722 |
super(0x1c, 4); |
| 723 |
} |
| 724 |
} |
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
public static class SetVariable extends SWFAction { |
| 730 |
public SetVariable() { |
| 731 |
super(0x1d, 4); |
| 732 |
} |
| 733 |
} |
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
public static class If extends SWFAction { |
| 739 |
private short offset; |
| 740 |
|
| 741 |
public If(short offset) { |
| 742 |
this(); |
| 743 |
this.offset = offset; |
| 744 |
} |
| 745 |
|
| 746 |
public If() { |
| 747 |
super(0x9d, 4); |
| 748 |
} |
| 749 |
|
| 750 |
public SWFAction read(int actionCode, SWFInputStream swf, int length) |
| 751 |
throws IOException { |
| 752 |
|
| 753 |
If action = new If(); |
| 754 |
action.offset = swf.readShort(); |
| 755 |
return action; |
| 756 |
} |
| 757 |
|
| 758 |
public void write(int actionCode, SWFOutputStream swf) |
| 759 |
throws IOException { |
| 760 |
|
| 761 |
swf.writeShort(offset); |
| 762 |
} |
| 763 |
|
| 764 |
public String toString() { |
| 765 |
return super.toString() + ", " + offset; |
| 766 |
} |
| 767 |
} |
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
public static class Call extends SWFAction { |
| 773 |
public Call() { |
| 774 |
super(0x9e, 4); |
| 775 |
} |
| 776 |
} |
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
public static class GotoFrame2 extends SWFAction { |
| 782 |
private byte play; |
| 783 |
|
| 784 |
public GotoFrame2(byte play) { |
| 785 |
this(); |
| 786 |
this.play = play; |
| 787 |
} |
| 788 |
|
| 789 |
public GotoFrame2() { |
| 790 |
super(0x9f, 4); |
| 791 |
} |
| 792 |
|
| 793 |
public SWFAction read(int actionCode, SWFInputStream swf, int length) |
| 794 |
throws IOException { |
| 795 |
|
| 796 |
GotoFrame2 action = new GotoFrame2(); |
| 797 |
action.play = swf.readByte(); |
| 798 |
return action; |
| 799 |
} |
| 800 |
|
| 801 |
public void write(int actionCode, SWFOutputStream swf) |
| 802 |
throws IOException { |
| 803 |
|
| 804 |
swf.writeByte(play); |
| 805 |
} |
| 806 |
|
| 807 |
public String toString() { |
| 808 |
return super.toString() + ", " + play; |
| 809 |
} |
| 810 |
} |
| 811 |
|
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
public static class SetTarget2 extends SWFAction { |
| 816 |
public SetTarget2() { |
| 817 |
super(0x20, 4); |
| 818 |
} |
| 819 |
} |
| 820 |
|
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
public static class StringAdd extends SWFAction { |
| 825 |
public StringAdd() { |
| 826 |
super(0x21, 4); |
| 827 |
} |
| 828 |
} |
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
public static class GetProperty extends SWFAction { |
| 834 |
public GetProperty() { |
| 835 |
super(0x22, 4); |
| 836 |
} |
| 837 |
} |
| 838 |
|
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
public static class SetProperty extends SWFAction { |
| 843 |
public SetProperty() { |
| 844 |
super(0x23, 4); |
| 845 |
} |
| 846 |
} |
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
public static class CloneSprite extends SWFAction { |
| 852 |
public CloneSprite() { |
| 853 |
super(0x24, 4); |
| 854 |
} |
| 855 |
} |
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
public static class RemoveSprite extends SWFAction { |
| 861 |
public RemoveSprite() { |
| 862 |
super(0x25, 4); |
| 863 |
} |
| 864 |
} |
| 865 |
|
| 866 |
|
| 867 |
|
| 868 |
|
| 869 |
public static class Trace extends SWFAction { |
| 870 |
public Trace() { |
| 871 |
super(0x26, 4); |
| 872 |
} |
| 873 |
} |
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
public static class StartDrag extends SWFAction { |
| 879 |
public StartDrag() { |
| 880 |
super(0x27, 4); |
| 881 |
} |
| 882 |
} |
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
public static class EndDrag extends SWFAction { |
| 888 |
public EndDrag() { |
| 889 |
super(0x28, 4); |
| 890 |
} |
| 891 |
} |
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
|
| 896 |
public static class StringLess extends SWFAction { |
| 897 |
public StringLess() { |
| 898 |
super(0x29, 4); |
| 899 |
} |
| 900 |
} |
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
public static class RandomNumber extends SWFAction { |
| 906 |
public RandomNumber() { |
| 907 |
super(0x30, 4); |
| 908 |
} |
| 909 |
} |
| 910 |
|
| 911 |
|
| 912 |
|
| 913 |
|
| 914 |
public static class MBStringLength extends SWFAction { |
| 915 |
public MBStringLength() { |
| 916 |
super(0x31, 4); |
| 917 |
} |
| 918 |
} |
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
public static class CharToAscii extends SWFAction { |
| 924 |
public CharToAscii() { |
| 925 |
super(0x32, 4); |
| 926 |
} |
| 927 |
} |
| 928 |
|
| 929 |
|
| 930 |
|
| 931 |
|
| 932 |
public static class AsciiToChar extends SWFAction { |
| 933 |
public AsciiToChar() { |
| 934 |
super(0x33, 4); |
| 935 |
} |
| 936 |
} |
| 937 |
|
| 938 |
|
| 939 |
|
| 940 |
|
| 941 |
public static class GetTime extends SWFAction { |
| 942 |
public GetTime() { |
| 943 |
super(0x34, 4); |
| 944 |
} |
| 945 |
} |
| 946 |
|
| 947 |
|
| 948 |
|
| 949 |
|
| 950 |
public static class MBStringExtract extends SWFAction { |
| 951 |
public MBStringExtract() { |
| 952 |
super(0x35, 4); |
| 953 |
} |
| 954 |
} |
| 955 |
|
| 956 |
|
| 957 |
|
| 958 |
|
| 959 |
public static class MBCharToAscii extends SWFAction { |
| 960 |
public MBCharToAscii() { |
| 961 |
super(0x36, 4); |
| 962 |
} |
| 963 |
} |
| 964 |
|
| 965 |
|
| 966 |
|
| 967 |
|
| 968 |
public static class MBAsciiToChar extends SWFAction { |
| 969 |
public MBAsciiToChar() { |
| 970 |
super(0x37, 4); |
| 971 |
} |
| 972 |
} |
| 973 |
|
| 974 |
|
| 975 |
|
| 976 |
|
| 977 |
|
| 978 |
public static class StoreRegister extends SWFAction { |
| 979 |
private byte number; |
| 980 |
|
| 981 |
public StoreRegister(byte number) { |
| 982 |
this(); |
| 983 |
this.number = number; |
| 984 |
} |
| 985 |
|
| 986 |
public StoreRegister() { |
| 987 |
super(0x87, 5); |
| 988 |
} |
| 989 |
|
| 990 |
public SWFAction read(int actionCode, SWFInputStream swf, int length) |
| 991 |
throws IOException { |
| 992 |
|
| 993 |
StoreRegister action = new StoreRegister(); |
| 994 |
action.number = swf.readByte(); |
| 995 |
return action; |
| 996 |
} |
| 997 |
|
| 998 |
public void write(int actionCode, SWFOutputStream swf) |
| 999 |
throws IOException { |
| 1000 |
|
| 1001 |
swf.writeByte(number); |
| 1002 |
} |
| 1003 |
|
| 1004 |
public String toString() { |
| 1005 |
return super.toString() + ", " + number; |
| 1006 |
} |
| 1007 |
} |
| 1008 |
|
| 1009 |
|
| 1010 |
|
| 1011 |
|
| 1012 |
public static class ConstantPool extends SWFAction { |
| 1013 |
private String[] pool; |
| 1014 |
|
| 1015 |
public ConstantPool(String[] pool) { |
| 1016 |
this(); |
| 1017 |
this.pool = pool; |
| 1018 |
} |
| 1019 |
|
| 1020 |
public ConstantPool() { |
| 1021 |
super(0x88, 5); |
| 1022 |
} |
| 1023 |
|
| 1024 |
public SWFAction read(int actionCode, SWFInputStream swf, int length) |
| 1025 |
throws IOException { |
| 1026 |
|
| 1027 |
ConstantPool action = new ConstantPool(); |
| 1028 |
action.pool = new String[swf.readUnsignedShort()]; |
| 1029 |
for (int i = 0; i < action.pool.length; i++) { |
| 1030 |
action.pool[i] = swf.readString(); |
| 1031 |
} |
| 1032 |
return action; |
| 1033 |
} |
| 1034 |
|
| 1035 |
public void write(int actionCode, SWFOutputStream swf) |
| 1036 |
throws IOException { |
| 1037 |
|
| 1038 |
swf.writeUnsignedShort(pool.length); |
| 1039 |
for (int i = 0; i < pool.length; i++) { |
| 1040 |
swf.writeString(pool[i]); |
| 1041 |
} |
| 1042 |
} |
| 1043 |
|
| 1044 |
public String toString() { |
| 1045 |
StringBuffer s = new StringBuffer(super.toString()); |
| 1046 |
s.append("["); |
| 1047 |
for (int i = 0; i < pool.length; i++) { |
| 1048 |
if (i != 0) |
| 1049 |
s.append(", "); |
| 1050 |
s.append(pool[i]); |
| 1051 |
} |
| 1052 |
s.append("]"); |
| 1053 |
return s.toString(); |
| 1054 |
} |
| 1055 |
} |
| 1056 |
|
| 1057 |
|
| 1058 |
|
| 1059 |
|
| 1060 |
public static class With extends SWFAction { |
| 1061 |
private int size; |
| 1062 |
|
| 1063 |
private String block; |
| 1064 |
|
| 1065 |
public With(int size, String block) { |
| 1066 |
this(); |
| 1067 |
this.size = size; |
| 1068 |
this.block = block; |
| 1069 |
} |
| 1070 |
|
| 1071 |
public With() { |
| 1072 |
super(0x94, 5); |
| 1073 |
} |
| 1074 |
|
| 1075 |
public SWFAction read(int actionCode, SWFInputStream swf, int length) |
| 1076 |
throws IOException { |
| 1077 |
|
| 1078 |
With action = new With(); |
| 1079 |
action.size = swf.readUnsignedShort(); |
| 1080 |
action.block = swf.readString(); |
| 1081 |
return action; |
| 1082 |
} |
| 1083 |
|
| 1084 |
public void write(int actionCode, SWFOutputStream swf) |
| 1085 |
throws IOException { |
| 1086 |
|
| 1087 |
swf.writeUnsignedShort(size); |
| 1088 |
swf.writeString(block); |
| 1089 |
} |
| 1090 |
|
| 1091 |
public String toString() { |
| 1092 |
return super.toString() + ", " + size + ", " + block; |
| 1093 |
} |
| 1094 |
} |
| 1095 |
|
| 1096 |
|
| 1097 |
|
| 1098 |
|
| 1099 |
public static class DefineFunction extends SWFAction { |
| 1100 |
private String name; |
| 1101 |
|
| 1102 |
private String[] params; |
| 1103 |
|
| 1104 |
private byte[] code; |
| 1105 |
|
| 1106 |
public DefineFunction(String name, String[] params, byte[] code) { |
| 1107 |
this(); |
| 1108 |
this.name = name; |
| 1109 |
this.params = params; |
| 1110 |
this.code = code; |
| 1111 |
} |
| 1112 |
|
| 1113 |
public DefineFunction() { |
| 1114 |
super(0x9b, 5); |
| 1115 |
} |
| 1116 |
|
| 1117 |
public SWFAction read(int actionCode, SWFInputStream swf, int length) |
| 1118 |
throws IOException { |
| 1119 |
|
| 1120 |
DefineFunction action = new DefineFunction(); |
| 1121 |
action.name = swf.readString(); |
| 1122 |
int n = swf.readUnsignedShort(); |
| 1123 |
for (int i = 0; i < n; i++) { |
| 1124 |
action.params[i] = swf.readString(); |
| 1125 |
} |
| 1126 |
int cs = swf.readUnsignedShort(); |
| 1127 |
action.code = swf.readByte(cs); |
| 1128 |
return action; |
| 1129 |
} |
| 1130 |
|
| 1131 |
public void write(int actionCode, SWFOutputStream swf) |
| 1132 |
throws IOException { |
| 1133 |
|
| 1134 |
swf.writeString(name); |
| 1135 |
swf.writeUnsignedShort(params.length); |
| 1136 |
for (int i = 0; i < params.length; i++) { |
| 1137 |
swf.writeString(params[i]); |
| 1138 |
} |
| 1139 |
swf.writeUnsignedShort(code.length); |
| 1140 |
swf.writeByte(code); |
| 1141 |
} |
| 1142 |
|
| 1143 |
public String toString() { |
| 1144 |
return super.toString() + ", " + name + ", " + (new String(code)); |
| 1145 |
} |
| 1146 |
} |
| 1147 |
|
| 1148 |
|
| 1149 |
|
| 1150 |
|
| 1151 |
public static class Delete extends SWFAction { |
| 1152 |
public Delete() { |
| 1153 |
super(0x3a, 5); |
| 1154 |
} |
| 1155 |
} |
| 1156 |
|
| 1157 |
|
| 1158 |
|
| 1159 |
|
| 1160 |
public static class Delete2 extends SWFAction { |
| 1161 |
public Delete2() { |
| 1162 |
super(0x3b, 5); |
| 1163 |
} |
| 1164 |
} |
| 1165 |
|
| 1166 |
|
| 1167 |
|
| 1168 |
|
| 1169 |
public static class DefineLocal extends SWFAction { |
| 1170 |
public DefineLocal() { |
| 1171 |
super(0x3c, 5); |
| 1172 |
} |
| 1173 |
} |
| 1174 |
|
| 1175 |
|
| 1176 |
|
| 1177 |
|
| 1178 |
public static class CallFunction extends SWFAction { |
| 1179 |
public CallFunction() { |
| 1180 |
super(0x3d, 5); |
| 1181 |
} |
| 1182 |
} |
| 1183 |
|
| 1184 |
|
| 1185 |
|
| 1186 |
|
| 1187 |
public static class Return extends SWFAction { |
| 1188 |
public Return() { |
| 1189 |
super(0x3e, 5); |
| 1190 |
} |
| 1191 |
} |
| 1192 |
|
| 1193 |
|
| 1194 |
|
| 1195 |
|
| 1196 |
public static class Modulo extends SWFAction { |
| 1197 |
public Modulo() { |
| 1198 |
super(0x3f, 5); |
| 1199 |
} |
| 1200 |
} |
| 1201 |
|
| 1202 |
|
| 1203 |
|
| 1204 |
|
| 1205 |
public static class NewObject extends SWFAction { |
| 1206 |
public NewObject() { |
| 1207 |
super(0x40, 5); |
| 1208 |
} |
| 1209 |
} |
| 1210 |
|
| 1211 |
|
| 1212 |
|
| 1213 |
|
| 1214 |
public static class DefineLocal2 extends SWFAction { |
| 1215 |
public DefineLocal2() { |
| 1216 |
super(0x41, 5); |
| 1217 |
} |
| 1218 |
} |
| 1219 |
|
| 1220 |
|
| 1221 |
|
| 1222 |
|
| 1223 |
public static class InitArray extends SWFAction { |
| 1224 |
public InitArray() { |
| 1225 |
super(0x42, 5); |
| 1226 |
} |
| 1227 |
} |
| 1228 |
|
| 1229 |
|
| 1230 |
|
| 1231 |
|
| 1232 |
public static class InitObject extends SWFAction { |
| 1233 |
public InitObject() { |
| 1234 |
super(0x43, 5); |
| 1235 |
} |
| 1236 |
} |
| 1237 |
|
| 1238 |
|
| 1239 |
|
| 1240 |
|
| 1241 |
public static class TypeOf extends SWFAction { |
| 1242 |
public TypeOf() { |
| 1243 |
super(0x44, 5); |
| 1244 |
} |
| 1245 |
} |
| 1246 |
|
| 1247 |
|
| 1248 |
|
| 1249 |
|
| 1250 |
public static class TargetPath extends SWFAction { |
| 1251 |
public TargetPath() { |
| 1252 |
super(0x45, 5); |
| 1253 |
} |
| 1254 |
} |
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
|
| 1259 |
public static class Enumerate extends SWFAction { |
| 1260 |
public Enumerate() { |
| 1261 |
super(0x46, 5); |
| 1262 |
} |
| 1263 |
} |
| 1264 |
|
| 1265 |
|
| 1266 |
|
| 1267 |
|
| 1268 |
public static class Add2 extends SWFAction { |
| 1269 |
public Add2() { |
| 1270 |
super(0x47, 5); |
| 1271 |
} |
| 1272 |
} |
| 1273 |
|
| 1274 |
|
| 1275 |
|
| 1276 |
|
| 1277 |
public static class Less2 extends SWFAction { |
| 1278 |
public Less2() { |
| 1279 |
super(0x48, 5); |
| 1280 |
} |
| 1281 |
} |
| 1282 |
|
| 1283 |
|
| 1284 |
|
| 1285 |
|
| 1286 |
public static class Equals2 extends SWFAction { |
| 1287 |
public Equals2() { |
| 1288 |
super(0x49, 5); |
| 1289 |
} |
| 1290 |
} |
| 1291 |
|
| 1292 |
|
| 1293 |
|
| 1294 |
|
| 1295 |
public static class ToNumber extends SWFAction { |
| 1296 |
public ToNumber() { |
| 1297 |
super(0x4a, 5); |
| 1298 |
} |
| 1299 |
} |
| 1300 |
|
| 1301 |
|
| 1302 |
|
| 1303 |
|
| 1304 |
public static class ToString extends SWFAction { |
| 1305 |
public ToString() { |
| 1306 |
super(0x4b, 5); |
| 1307 |
} |
| 1308 |
} |
| 1309 |
|
| 1310 |
|
| 1311 |
|
| 1312 |
|
| 1313 |
public static class PushDuplicate extends SWFAction { |
| 1314 |
public PushDuplicate() { |
| 1315 |
super(0x4c, 5); |
| 1316 |
} |
| 1317 |
} |
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
|
| 1322 |
public static class StackSwap extends SWFAction { |
| 1323 |
public StackSwap() { |
| 1324 |
super(0x4d, 5); |
| 1325 |
} |
| 1326 |
} |
| 1327 |
|
| 1328 |
|
| 1329 |
|
| 1330 |
|
| 1331 |
public static class GetMember extends SWFAction { |
| 1332 |
public GetMember() { |
| 1333 |
super(0x4e, 5); |
| 1334 |
} |
| 1335 |
} |
| 1336 |
|
| 1337 |
|
| 1338 |
|
| 1339 |
|
| 1340 |
public static class SetMember extends SWFAction { |
| 1341 |
public SetMember() { |
| 1342 |
super(0x4f, 5); |
| 1343 |
} |
| 1344 |
} |
| 1345 |
|
| 1346 |
|
| 1347 |
|
| 1348 |
|
| 1349 |
public static class Increment extends SWFAction { |
| 1350 |
public Increment() { |
| 1351 |
super(0x50, 5); |
| 1352 |
} |
| 1353 |
} |
| 1354 |
|
| 1355 |
|
| 1356 |
|
| 1357 |
|
| 1358 |
public static class Decrement extends SWFAction { |
| 1359 |
public Decrement() { |
| 1360 |
super(0x51, 5); |
| 1361 |
} |
| 1362 |
} |
| 1363 |
|
| 1364 |
|
| 1365 |
|
| 1366 |
|
| 1367 |
public static class CallMethod extends SWFAction { |
| 1368 |
public CallMethod() { |
| 1369 |
super(0x52, 5); |
| 1370 |
} |
| 1371 |
} |
| 1372 |
|
| 1373 |
|
| 1374 |
|
| 1375 |
|
| 1376 |
public static class NewMethod extends SWFAction { |
| 1377 |
public NewMethod() { |
| 1378 |
super(0x53, 5); |
| 1379 |
} |
| 1380 |
} |
| 1381 |
|
| 1382 |
|
| 1383 |
|
| 1384 |
|
| 1385 |
public static class BitAnd extends SWFAction { |
| 1386 |
public BitAnd() { |
| 1387 |
super(0x60, 5); |
| 1388 |
} |
| 1389 |
} |
| 1390 |
|
| 1391 |
|
| 1392 |
|
| 1393 |
|
| 1394 |
public static class BitOr extends SWFAction { |
| 1395 |
public BitOr() { |
| 1396 |
super(0x61, 5); |
| 1397 |
} |
| 1398 |
} |
| 1399 |
|
| 1400 |
|
| 1401 |
|
| 1402 |
|
| 1403 |
public static class BitXor extends SWFAction { |
| 1404 |
public BitXor() { |
| 1405 |
super(0x62, 5); |
| 1406 |
} |
| 1407 |
} |
| 1408 |
|
| 1409 |
|
| 1410 |
|
| 1411 |
|
| 1412 |
public static class BitLShift extends SWFAction { |
| 1413 |
public BitLShift() { |
| 1414 |
super(0x63, 5); |
| 1415 |
} |
| 1416 |
} |
| 1417 |
|
| 1418 |
|
| 1419 |
|
| 1420 |
|
| 1421 |
public static class BitRShift extends SWFAction { |
| 1422 |
public BitRShift() { |
| 1423 |
super(0x64, 5); |
| 1424 |
} |
| 1425 |
} |
| 1426 |
|
| 1427 |
|
| 1428 |
|
| 1429 |
|
| 1430 |
public static class BitURShift extends SWFAction { |
| 1431 |
public BitURShift() { |
| 1432 |
super(0x65, 5); |
| 1433 |
} |
| 1434 |
} |
| 1435 |
|
| 1436 |
|
| 1437 |
|
| 1438 |
|
| 1439 |
public static class InstanceOf extends SWFAction { |
| 1440 |
public InstanceOf() { |
| 1441 |
super(0x54, 6); |
| 1442 |
} |
| 1443 |
} |
| 1444 |
|
| 1445 |
|
| 1446 |
|
| 1447 |
|
| 1448 |
public static class Enumerate2 extends SWFAction { |
| 1449 |
public Enumerate2() { |
| 1450 |
super(0x55, 6); |
| 1451 |
} |
| 1452 |
} |
| 1453 |
|
| 1454 |
|
| 1455 |
|
| 1456 |
|
| 1457 |
public static class StrictEquals extends SWFAction { |
| 1458 |
public StrictEquals() { |
| 1459 |
super(0x66, 6); |
| 1460 |
} |
| 1461 |
} |
| 1462 |
|
| 1463 |
|
| 1464 |
|
| 1465 |
|
| 1466 |
public static class Greater extends SWFAction { |
| 1467 |
public Greater() { |
| 1468 |
super(0x67, 6); |
| 1469 |
} |
| 1470 |
} |
| 1471 |
|
| 1472 |
|
| 1473 |
|
| 1474 |
|
| 1475 |
public static class StringGreater extends SWFAction { |
| 1476 |
public StringGreater() { |
| 1477 |
super(0x68, 6); |
| 1478 |
} |
| 1479 |
} |
| 1480 |
} |