1 50 51 package org.openlaszlo.iv.flash.commands; 52 53 import org.openlaszlo.iv.flash.parser.*; 54 import org.openlaszlo.iv.flash.api.*; 55 import org.openlaszlo.iv.flash.api.image.*; 56 import org.openlaszlo.iv.flash.api.shape.*; 57 import org.openlaszlo.iv.flash.util.*; 58 import org.openlaszlo.iv.flash.cache.*; 59 import org.openlaszlo.iv.flash.url.*; 60 61 import org.openlaszlo.iv.flash.context.Context; 62 import java.io.*; 63 64 public class InsertPngFileCommand extends GenericCommand { 65 66 public InsertPngFileCommand() {} 67 68 public void doCommand( FlashFile file, Context context, Script parent, int frame ) throws IVException { 69 String filename = getParameter( context, "filename", "" ); 70 boolean scale = getBoolParameter( context, "scale", false ); 71 boolean cache = getBoolParameter( context, "cache", false ); 74 String instancename = getParameter( context, "instancename" ); 76 77 Bitmap bitmap = null; 78 try { 79 bitmap = (Bitmap) file.addExternalMedia(filename, cache); 80 } catch( IOException e ) { 81 throw new IVException(Resource.ERRCMDFILEREAD, new Object [] {filename, getCommandName()}, e); 82 } 83 84 Instance myInst = bitmap.newInstance( 2048, 2048, scale, true ); 85 86 Instance inst = getInstance(); 87 Script script = inst.copyScript(); 88 Frame myFrame = script.newFrame(); 89 myFrame.addInstance( myInst, 1 ); 90 91 script.newFrame().addInstance(1, null); 94 95 if( instancename != null ) { 96 inst.name = instancename; 97 } 98 } 99 100 } 101 | Popular Tags |