<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
    layout="absolute"
    pageTitle="Pong" backgroundColor="#000000"
    xmlns:maps="game.pong.maps.*"
    applicationComplete="registerGlobalKeyHandler()" xmlns:views="game.pong.views.*" viewSourceURL="srcview/index.html">
    
    <!--**********************************************************************
            
            Flex Pong or my take on Pong using Flex, Away3D, Mate and Degrafa
            Overkill? Mmmhhh... Yeah! But that's where the fun is!
            
            (very) Freely adapted from Jackson Dunstan's AS3 Ping Pong 
            (http://www.rapo.org/as3/examples/pong/) 
            
        **********************************************************************-->
    
    <!-- Styles used for the "regular" Pong -->
    <mx:Style source="css/mainStyle.css" />
    
    <mx:Script>
        <![CDATA[
            import game.pong.events.PongKeysEvent;
            
            public function registerGlobalKeyHandler() :void
            {
                // KeyboardEvent listener to catch user's interaction
                stage.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown);
            }
            
            public function handleKeyDown(event:KeyboardEvent) :void
            {
                switch (event.keyCode)
                {
                    // Key "R" was pressed so Restart event is dispatched
                    case 82:
                        dispatchEvent(new PongKeysEvent(PongKeysEvent.RESTART));
                        break;
                    // Key "T" was pressed so Turbocharge event is dispatched
                    case 84:
                        dispatchEvent(new PongKeysEvent(PongKeysEvent.TURBOCHARGE));
                        break;
                }
            }
        ]]>
    </mx:Script>

    <!-- Mate framework's "core": the eventMap -->
    <maps:MainEventMap />
    
    <!-- The main view -->
    <views:MainView id="mainView" 
        horizontalCenter="0" verticalCenter="0"/>
    
</mx:Application>