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

package com.macromedia.generator.commands;

import com.macromedia.generator.api.*;
import com.macromedia.generator.app.*;
import com.macromedia.generator.platform.Mac;
import java.io.File;
import java.util.Properties;

public class AddExternalMediaCommand extends GenericCommand
{

    public AddExternalMediaCommand()
    {
    }

    public void doCommand(FlashEnvironment flashenvironment, Script script, Context context, int i, Properties properties)
        throws FlashCommandException
    {
        Mac mac = Mac.getMac();
        _fld0109 = new GenVector();
        String s = properties.getProperty("mediafile", "");
        s = context.apply(s);
        File file;
        if(mac != null)
        {
            String s1 = mac.makeJavaPretty(s);
            file = new File(s1);
            if(!file.exists() || !file.isFile())
                file = new File(s1.substring(1));
        } else
        {
            file = new File(s);
        }
        if(!file.isAbsolute())
            file = new File(flashenvironment.getDirectory(), file.getPath());
        if(!file.exists() || !file.isFile())
        {
            logError(flashenvironment, "MediaFileError", s);
            return;
        }
        try
        {
            Script script1 = (Script)_fld0109.add(new Script());
            script1.setFileVersion(script.getFileVersion());
            script1.setFile(file.getPath(), flashenvironment.getPreviewMode() ^ true);
            CacheManager cachemanager = flashenvironment.getCacheManager();
            if(cachemanager != null)
                cachemanager.loadExternalFonts(flashenvironment, script1);
            try
            {
                script.addExternalMedia(script1);
            }
            catch(GeneratorApiException _ex)
            {
                logError(flashenvironment, "UnableToAddMedia", s);
            }
        }
        catch(GeneratorApiException _ex)
        {
            logError(flashenvironment, "MediaFileError", s);
        }
        _fld0109.release();
    }

    GenVector _fld0109;
}