views:

663

answers:

2

(This is a question for Flash 9/10 AS3.)

I'm trying to solve a problem where the user has to click on an area before it starts getting mouse wheel events.

I assume the focus is set elsewhere so in the ctor for my movieclip that is asking for events, I say "stage.focus = this". This ought to work, judging from the web searches I did. But it doesn't. I still have to click on the clip before it starts hearing mouse wheel events.

What could I be doing wrong here? This is basic AS3 stuff in the Flash IDE, running through the IDE as a test (not hosted on a web page yet), no Flex, no components..

The wheel events come through great and work perfectly, but I want to avoid having to do that initial click.

A: 

are you sure that the browser has the focus and the movie has the focus ? in some cases we had to use a simple javascript to set the focus on the movieclip. For example if your Flash has the id 'flashVideo' a simple document.getElementById('flashVideo').focus() can do the work. You can do a better job using a javascript framework to ensure that you run your code when the DOM is ready. For example in jQuery you can use something like this:

jQuery(document).ready(function(){
    jQuery('#flashVideo').focus();
})
wezzy
I'm currently not even testing in a browser. Just by ctrl-enter from the Flash IDE. So, from within the standalone Flash player.
Scott Bilas
+2  A: 

stage.focus is for keyboard focus. Set tabEnabled = true; for the respective sprite and then hit tab to bring the display object into focus. You might wanna set stageFocusRect = false; to avoid a yellow rectangle being shown around the focused display object.

Amarghosh