package;
 
import openfl.display.Sprite;
import openfl.events.MouseEvent;
 
/**
 * Class that demonstrates the most basic mouse interactivity
 */
class Main extends Sprite 
{
 
    public function new () 
    {
        super ();
 
        var button:Button = new Button();
        button.x = button.y = 20;
        button.addEventListener( MouseEvent.CLICK, onClick );
 
        addChild( button );
    }
 
    /**
     * Eventhandler
     *
     * @param event     The event object with information on the event
     */
    function onClick( event:MouseEvent )
    {
        trace( "You clicked on" + event.currentTarget );
    }
}
 
/**
 * A basic class to be used as a button
 *
 */
class Button extends Sprite
{
    public function new()
    {
        super();
 
        drawBasicRect();
    }
 
    function drawBasicRect()
    {
        this.graphics.beginFill( 0xFF0000 );
        this.graphics.drawRoundRect( 0, 0, 80, 20, 10, 10 );
        this.graphics.endFill();
    }
}