[haXe] AS3 addEventListener for keydown

Sebastian Lucas delsilucas at gmail.com
Wed Sep 27 16:37:09 CEST 2006


Hi Nicolas,
Here's the source:
(It's just a test, that's why it's a mess!):

import flash.Lib;
import flash.display.MovieClip;
import flash.events.IEventDispatcher;
import flash.events.EventDispatcher;
import flash.events.KeyboardEvent;
import flash.events.Event;
import flash.display.Stage;

class TestAS3
{
    /*
     * Variables
     */
    private var eventDispatcher:EventDispatcher;
    private var keyer:KeyboardEvent;

    /*
     * Constructor
     */
    public function new ()
    {
        trace ("constructor");

        eventDispatcher = new EventDispatcher ();
        keyer=new KeyboardEvent("KEY_DOWN");

        Lib.current.addEventListener (Event.ENTER_FRAME, update);
        Lib.current.addEventListener (KeyboardEvent.KEY_DOWN, keydown);
    }

    /*
     * Main
     */
    static function main()
    {
        new TestAS3 ();
    }

    /*
     * keydown
     */
    function keydown (event:KeyboardEvent)
    {
        trace ("a key was pressed");
    }

    /*
     * update
     */
    function update (event:Event)
    {
    }
}

Thanks again.

On 9/27/06, Nicolas Cannasse <ncannasse at motion-twin.com> wrote:
>
> > Hi,
> >
> > Im new on this list, so, here is my problem:
>
> Could you post a complete class sample including the code you're using
> to compile ?
>
> Nicolas
>
> --
> haXe - an open source web programming language
> http://haxe.org
>



-- 
█║▌│█│║▌║││█║▌│║
Sebastian Javier Lucas
Programmer & Guitar Hero
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.motion-twin.com/pipermail/haxe/attachments/20060927/8191081b/attachment.htm


More information about the Haxe mailing list