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.util.*; 56 import org.openlaszlo.iv.flash.context.Context; 57 import org.openlaszlo.iv.flash.context.GraphContext; 58 import java.io.*; 59 import java.util.*; 60 61 public class XMLReplicateMovieClipCommand extends GenericXMLCommand { 62 63 public XMLReplicateMovieClipCommand() {} 64 65 public void doCommand( FlashFile file, Context context, Script parent, int frameNum ) throws IVException 66 { 67 super.initParms( context ); 68 69 71 boolean expand = getBoolParameter( context, "expand", true ); 72 73 int order; 74 String sorder = getParameter( context, "order", "none" ); 75 76 if ( sorder.equalsIgnoreCase( "descending" ) ) order = -1; 77 else if ( sorder.equalsIgnoreCase( "ascending" ) ) order = 1; 78 else order = 0; 79 80 String sortby = getParameter( context, "sortby", "'none'" ); 81 82 84 GraphContext gc = getGraphContext( file, context ); 85 86 88 List contextList = gc.getValueList( select ); 89 90 92 if ( order != 0 ) 93 { 94 contextList = GraphContext.sortValueList( contextList, sortby, order == 1 ); 95 } 96 97 Instance inst = getCommandInstance(file, context, parent, frameNum); 98 Script template = inst.getScript(); 99 100 Script newScript = new Script(20); 101 102 104 Context myContext; 105 ListIterator iter = contextList.listIterator(); 106 107 int totalFrames = 0; 108 while( iter.hasNext() ) 109 { 110 myContext = ( Context ) iter.next(); 111 112 Script myScript = template.copyScript(); 113 file.processScript( myScript, myContext ); 114 115 totalFrames += myScript.getFrameCount(); 116 117 myScript.reserveLayers(1, newScript.getMaxDepth()); 119 120 newScript.appendScript( myScript ); 121 } 122 123 inst.setScript( newScript ); 124 125 if( expand && !isComponent() ) { 126 parent.getFrameAt(frameNum+totalFrames-1); 128 } 129 } 130 131 } 132 | Popular Tags |