// Decompiled by DJ v2.6.6.51 Copyright 2000 Atanas Neshkov  Date: 6/15/2001 17:06:11
// 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/InsertMovieClipCommand

package com.macromedia.generator.commands;

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

public class InsertMovieClipCommand extends GenericCommand
{

    public InsertMovieClipCommand()
    {
    }

    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("name", "");
        String s1 = properties.getProperty("scale", "false");
        String s2 = properties.getProperty("instancename", "");
        s = context.apply(s);
        s1 = context.apply(s1);
        s2 = context.apply(s2);
        if(s == null)
        {
            logError(flashenvironment, "MissingSymbolName", null);
            return;
        }
        Script script2 = (Script)_fld0109.add(script.findScript(s));
        if(script2 == null)
            script2 = (Script)_fld0109.add(flashenvironment.getTemplate().findScript(s));
        if(script2 != null)
            try
            {
                Script script3 = (Script)_fld0109.add(script2.copyScript());
                flashenvironment.processScript(script3, context);
                script.setCommandScript(i, script3);
                if(s1.equalsIgnoreCase("true"))
                {
                    Rect rect = (Rect)_fld0109.add(script3.getBounds());
                    int j = rect.getXMax() - rect.getXMin();
                    int k = rect.getYMax() - rect.getYMin();
                    Matrix matrix = (Matrix)_fld0109.add(new Matrix());
                    matrix.setXScale(1.0F / ((float)j / 2048F));
                    matrix.setYScale(1.0F / ((float)k / 2048F));
                    script.setCommandMatrix(i, matrix);
                }
                if(s2 != null)
                    script.setCommandLabel(i, s2);
            }
            catch(GeneratorApiException _ex)
            {
                logError(flashenvironment, "UnableToInsertSymbol", s);
            }
        else
            logError(flashenvironment, "UnableToFindSymbol", s);
        _fld0109.release();
    }

    GenVector _fld0109;
}