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 ActionCondition extends FlashItem { 60 61 public static int OverDownToIdle = 0x0100; public static int IdleToOverDown = 0x0080; public static int OutDownToIdle = 0x0040; public static int OutDownToOverDown = 0x0020; public static int OverDownToOutDown = 0x0010; public static int OverDownToOverUp = 0x0008; public static int OverUpToOverDown = 0x0004; public static int OverUpToIdle = 0x0002; public static int IdleToOverUp = 0x0001; 72 private int condition; 73 private Program program; 74 75 public ActionCondition() {} 76 77 public ActionCondition( int condition, Program program ) { 78 this.condition = condition; 79 this.program = program; 80 } 81 82 88 public static ActionCondition onOut( Program program ) { 89 return new ActionCondition(OverUpToIdle|OverDownToIdle|OverDownToOutDown, program); 90 } 91 92 98 public static ActionCondition onOver( Program program ) { 99 return new ActionCondition(IdleToOverUp|IdleToOverDown|OutDownToOverDown, program); 100 } 101 102 108 public static ActionCondition onRollOut( Program program ) { 109 return new ActionCondition(OverUpToIdle, program); 110 } 111 112 118 public static ActionCondition onRollOver( Program program ) { 119 return new ActionCondition(IdleToOverUp, program); 120 } 121 122 128 public static ActionCondition onPress( Program program ) { 129 return new ActionCondition(OverUpToOverDown, program); 130 } 131 132 138 public static ActionCondition onDragOut( Program program ) { 139 return new ActionCondition(OverDownToIdle|OverDownToOutDown, program); 140 } 141 142 148 public static ActionCondition onDragOver( Program program ) { 149 return new ActionCondition(IdleToOverDown|OutDownToOverDown, program); 150 } 151 152 158 public static ActionCondition onReleaseOutside( Program program ) { 159 return new ActionCondition(OutDownToIdle, program); 160 } 161 162 168 public static ActionCondition onRelease( Program program ) { 169 return new ActionCondition(OverDownToOverUp, program); 170 } 171 172 179 public static ActionCondition onKeyPress( char ch, Program program ) { 180 return new ActionCondition((ch<<1)&0xfe, program); 181 } 182 183 public void setCondition( int condition ) { this.condition = condition; } 184 public void setProgram( Program program ) { this.program = program; } 185 186 public int getCondition() { return condition; } 187 public Program getProgram() { return program; } 188 189 public void write( FlashOutput fob ) { 190 fob.writeWord(condition); 191 program.write(fob); 192 } 193 194 public void printContent( PrintStream out, String indent ) { 195 out.println( indent+" ActionCondition: condition="+Util.w2h(condition) ); 196 program.printContent(out, indent+" "); 197 } 198 199 public FlashItem getCopy( ScriptCopier copier ) { 200 return new ActionCondition( condition, (Program) program.getCopy(copier) ); 201 } 202 203 } 204 205 | Popular Tags |