[osflash] Am I overlooking any crucial tools?

izak marais izakmarais at yahoo.com
Tue Aug 19 11:15:34 PDT 2008


Ok, thanks for the help, I will post language questions elsewhere in future. For interest sake (from the Actionscript 3 programming guide) :

"To ensure that your program responds to events, you must add event listeners, either to the event target or to any display list object that is part of an event object’s event flow."

which explains why your examples worked and mine didn't.
Izak



----- Original Message ----
From: Scott Langeberg <slangeberg at gmail.com>
To: Open Source Flash Mailing List <osflash at osflash.org>
Sent: Tuesday, August 19, 2008 5:24:59 PM
Subject: Re: [osflash] Am I overlooking any crucial tools?


Yes, new thread would be better. And also probably the wrong group, as there is also flashcoders, flexcoders, etc.

Simple (not best?) answer is to add listeners to the full app, such as:

this.parent.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown)     
this.parent.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown)   

And you must first click into the app. Your code would work, if you clicked the text, as the parent Sprite only stretched to contain the TextField.

I normally do flex projects, so am only guessing in AS project, but this change did work for me.

-Scott


On Tue, Aug 19, 2008 at 9:59 AM, izak marais <izakmarais at yahoo.com> wrote:

Hi there,

I don't know if it might be better to start a new thread, but this question is related to porting my code from AS2 to AS3 as suggested in this thread. Can anyone please help? It is (I think) a simple problem.

I can't get keyboard and mouse events to function properly. KeyBoard events (KEY_DOWN) don't seem to have any effect while mouse events only work occasionally. Below  is a minimal example. When I run it and press keys and the mouse (while flash has focus), I occasionaly  see "onMouseDown():called", although  it is very random, the number of traces is much fewer than the amount of actual mouse presses and generelly require at least 2 seconds between presses to register (although sometimes it does not work even when I wait longer). Key presses do not result in any traced output. 

(I did check wheter the problem perhaps lies with "trace()" by doing someting in the event-functions, but this is not the case).

Please help somebody! 
Thanks
Izak


"
package { 
    import flash.display.Sprite; 
    import flash.text.TextField; 
    import flash.events.KeyboardEvent 
    import flash.events.MouseEvent 

     
    public class HelloWorld extends Sprite { 
         
        public function HelloWorld() { 
            var display_txt:TextField = new TextField(); 
            var i:int; 
            trace("HelloWorld():called") 

            display_txt.text = "Hello World!"; 
             
            addChild(display_txt) 
            addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown)     
            addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown) 
             
        } 
         
        public function onKeyDown(event:KeyboardEvent):void { 
            trace("onKeyDown():called with "+event.charCode+", "+event.keyCode) 
        } 
         
        public function onMouseDown(event:MouseEvent):void { 
            trace("onMouseDown():called")     
        } 
    } 
} 
"



----- Original Message ----
From: Niels Wolf <niels.wolf at mediacatalyst.com>

To: Open Source Flash Mailing List <osflash at osflash.org>

Sent: Tuesday, August 12, 2008 6:51:33 PM
Subject: Re: [osflash] Am I overlooking any crucial tools?

@Daren.. Thanks, but we use our own logging system that has different output options.


On 8/12/08 1:42 PM, "izak marais" <izakmarais at yahoo.com> wrote:


@Niels: Thanks for clearing up my misunderstanding. 
@Daren: With AS2 I had been using a similar custom class to write to the top-level of the movie; based on that I had completely the wrong idea of what trace() should do. I'll try using trace() and 'tail' to output to shell and file; it seems useful. 

 Original Message ----
From: Darren Cook <darren at dcook.org>
To: Open Source Flash Mailing List <osflash at osflash.org>
Sent: Tuesday, August 12, 2008 12:51:11 PM
Subject: Re: [osflash] Am I overlooking any crucial tools?

>> When you right-click the debug player you'll see an option there
>> called "Debugger".
> 
> Yes, but clicking on that does nothing as far as I can tell. (Perhaps
> it would link to the flex builder debugger if one had that...)

Sorry for the confusion; I just meant as a way to identify that you are
using the debug player. Like you Debugger doesn't actually do anything
for me.

BTW, I have a Logger class that has an option to write to the top-level
of the movie, and hide/show with the D key. It is open source (as soon
as I get around to doing a release); if you want a copy before then let
me know.

Darren


 

_______________________________________________
osflash mailing list
osflash at osflash.org
http://osflash.org/mailman/listinfo/osflash_osflash.org




-- 
: : ) Scott

Helping your grandma on the interweb
at: http://blog.criticalpile.com



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/osflash_osflash.org/attachments/20080819/8fa3eebb/attachment.html 


More information about the osflash mailing list