// Decompiled by DJ v2.6.6.51 Copyright 2000 Atanas Neshkov  Date: 6/15/2001 17:06:25
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   com/macromedia/generator/commands/ReplicateMovieClipCommand

package com.macromedia.generator.commands;

import com.macromedia.generator.api.*;
import com.macromedia.generator.app.*;
import java.util.Properties;

public class ReplicateMovieClipCommand extends GenericCommand
{

    public ReplicateMovieClipCommand()
    {
    }

    public void doCommand(FlashEnvironment flashenvironment, Script script, Context context, int i, Properties properties)
        throws FlashCommandException
    {
        _fld0109 = new GenVector(16);
        Script script1 = (Script)_fld0109.add(script.getCommandScript(i));
        String s = properties.getProperty("datasource", "");
        String s1 = properties.getProperty("expand", "true");
        s = context.apply(s);
        s1 = context.apply(s1);
        UrlDataSource urldatasource = new UrlDataSource();
        urldatasource.setEnvironment(flashenvironment);
        String as[][] = urldatasource.getData(s);
        try
        {
            if(as == null)
            {
                logError(flashenvironment, "DataSourceFormatError", s);
                script.setCommandScript(i, null);
                _fld0109.release();
                return;
            }
            if(as.length < 2)
            {
                logError(flashenvironment, "DataSourceFormatError", s);
                script.setCommandScript(i, null);
                _fld0109.release();
                return;
            }
            Script script2 = (Script)_fld0109.add(new Script());
            script2.setFileVersion(script.getFileVersion());
            boolean flag = false;
            for(int j = 1; j < as.length; j++)
            {
                Context context1 = (Context)_fld0109.add(new Context());
                context1.setParent(context);
                for(int l = 0; l < as[j].length; l++)
                    context1.setValue(as[0][l], as[j][l]);

                Script script3 = (Script)_fld0109.add(script1.copyScript());
                flashenvironment.processScript(script3, context1);
                script2.appendScript(script3);
                _fld0109.release(context1);
                _fld0109.release(script3);
            }

            script.setCommandScript(i, script2);
            if(s1.equalsIgnoreCase("true"))
            {
                int k = 0;
                int i1 = script2.getLastFrame();
                int j1 = script.getCommandFrameIndex(i);
                int k1 = script.getCommandFrameCount(i);
                if(i1 > k1)
                    k = i1 - k1;
                if(k > 0)
                    script.insertFrames(j1, k);
            }
            _fld0109.release(script2);
        }
        catch(GeneratorApiException _ex)
        {
            logError(flashenvironment, "ErrorReplicatingClips", null);
        }
        _fld0109.release();
    }

    GenVector _fld0109;
}