package flater.cairngormtips.controller.commands
{

import com.adobe.cairngorm.control.CairngormEvent;
import com.universalmind.cairngorm.commands.Command;

import flater.cairngormtips.controller.delegates.EventGeneratorExampleDelegate;
import flater.cairngormtips.controller.events.DownloadSomethingEvent;
import flater.cairngormtips.util.out;

/**
 *  Downloads the resource specified by the DownloadSomethingEvent
 *  url property.</br> 
 *  <br/>
 *  Author: <a href="http://www.adamflater.net" target="_blank">
 *  Adam Flater</a>
 *  <br/>
 *  @see flater.cairngormtips.controller.events.DownloadSomethingEvent                                                                                          
 *  @see flater.cairngormtips.controller.delegates.EventGeneratorExampleDelegate
 *  @see flater.cairngormtips.EventGeneratorExampleApplication                                                                                          
 */
public class DownloadCommand extends Command
{
    public function DownloadCommand()
    {
        super();
        
        out( "DownloadCommand Instantiated" );
    }
    
    override public function execute( event : CairngormEvent ) : void
    {
        super.execute( event );
        
        out( "DownloadCommand.execute() invoked" );
          
        var e : DownloadSomethingEvent = event as DownloadSomethingEvent;
        
        var delegate : EventGeneratorExampleDelegate = 
                          new EventGeneratorExampleDelegate( this );
            delegate.downloadSomthing( e.url );     
    }
    
    override public function result( info : Object ) : void
    {
        out( "DownloadCommand.result() invoked" );

        notifyCaller( info );
    }
    
} //  end class
} //  end package