1 50 51 package org.openlaszlo.iv.flash.commands; 52 53 import java.io.*; 54 import org.openlaszlo.iv.flash.parser.*; 55 import org.openlaszlo.iv.flash.api.*; 56 import org.openlaszlo.iv.flash.util.*; 57 58 import org.openlaszlo.iv.flash.context.Context; 59 60 public class ReplicateMovieClipCommand extends GenericCommand { 61 62 public ReplicateMovieClipCommand() {} 63 64 public void doCommand( FlashFile file, Context context, Script parent, int frameNum ) throws IVException { 65 String datasource = getParameter( context, "datasource" ); 66 boolean expand = getBoolParameter( context, "expand", true ); 67 68 Instance inst = getCommandInstance(file, context, parent, frameNum); 69 Script template = inst.getScript(); 71 73 String [][] data; 74 try { 75 UrlDataSource ds = new UrlDataSource(datasource,file); 76 data = ds.getData(); 77 } catch( IOException e ) { 78 throw new IVException(Resource.ERRDATAREAD, new Object [] {datasource, getCommandName()}, e); 79 } 80 81 if( data.length < 1 ) { 82 throw new IVException( Resource.INVALDATASOURCE, new Object [] {datasource, getCommandName()} ); 83 } 84 85 Script newScript = new Script(20); 86 87 int totalFrames = 0; 88 for( int row=1; row<data.length; row++ ) { 89 Context myContext = makeContext( context, data, row ); 90 Script myScript = template.copyScript(); 91 file.processScript( myScript, myContext ); 92 totalFrames += myScript.getFrameCount(); 93 myScript.reserveLayers(1, newScript.getMaxDepth()); newScript.appendScript( myScript ); 95 } 96 97 inst.setScript( newScript ); 98 99 if( expand && !isComponent() ) { 100 parent.getFrameAt(frameNum+totalFrames-1); 102 } 103 } 104 105 } 106 | Popular Tags |