1 50 51 package org.openlaszlo.iv.flash.api.button; 52 53 import java.io.PrintStream ; 54 import org.openlaszlo.iv.flash.util.*; 55 import org.openlaszlo.iv.flash.parser.*; 56 import org.openlaszlo.iv.flash.api.*; 57 import org.openlaszlo.iv.flash.api.action.*; 58 59 public class Button2 extends Button { 60 61 public static final int TrackAsMenu = 1; 62 public static final int TrackAsButton = 0; 63 64 protected int track; 65 66 public Button2() {} 67 68 public int getTag() { 69 return Tag.DEFINEBUTTON2; 70 } 71 72 public void setTrackAs( int track ) { this.track = track; } 73 public int getTrackAs() { return track; } 74 75 public static Button2 parse2( Parser p ) { 76 Button2 o = new Button2(); 77 o.setID( p.getUWord() ); 78 o.track = p.getUByte(); 79 int actionsOffset = p.getPos(); 80 int nextOff = p.getUWord(); 81 o.parseButtonRecords(p,true); 82 83 while(nextOff>0) { 85 actionsOffset += nextOff; 86 p.setPos(actionsOffset); 87 nextOff = p.getUWord(); 88 int endOff = nextOff == 0? p.getTagEndPos(): actionsOffset+nextOff; 89 int cond = p.getUWord(); 90 Program prog = new Program( p.getBuf(), p.getPos(), endOff ); 91 o.addActionCondition( new ActionCondition( cond, prog ) ); 92 } 93 94 return o; 95 } 96 97 public void write( FlashOutput fob ) { 98 int pos = fob.getPos(); 99 fob.skip(6); 100 fob.writeDefID( this ); 101 fob.writeByte(track); 102 103 int actionOffsetPos = fob.getPos(); 104 fob.writeWord(0); 105 106 writeButtonRecords(fob); 107 108 for( int i=0; i<conditions.size(); i++ ) { 109 ActionCondition ac = (ActionCondition) conditions.elementAt(i); 110 fob.writeWordAt(fob.getPos()-actionOffsetPos, actionOffsetPos); 111 actionOffsetPos = fob.getPos(); 112 fob.writeWord(0); 113 ac.write(fob); 114 } 115 116 fob.writeLongTagAt(getTag(), fob.getPos()-pos-6, pos); 117 118 writeExternals( fob ); } 120 121 protected FlashItem copyInto( FlashItem item, ScriptCopier copier ) { 122 super.copyInto( item, copier ); 123 ((Button2)item).track = track; 124 return item; 125 } 126 127 public FlashItem getCopy( ScriptCopier copier ) { 128 return copyInto( new Button2(), copier ); 129 } 130 } 131 132 | Popular Tags |