Tuesday, April 11, 2006

wmode = transparent in FF plugin - its Key.isDown() this time!

Had there never been transparent windowless mode (wmode), I wouldn’t have proposed a solution using it, to my team. And it wouldn’t have fired back on me now.

As I had mentioned in a previous post I had problems with wmode onMouseWheel event. Finally we ended up with a workaround for this, using our good old hitTest method. Not a great work around, but solved our purpose.

Today pick is the Key.isDown method. With wmode=”transparent”, Key.isDown always returns false even when the corresponding key is pressed.

Try this:

Reproduction steps:

  1. Create a movie with a text field on stage( give it a instance name “log”).
  2. Draw some shape. Make it a button. On that button have the following code:


on (keyPress "")

{

_root.log.text += "\nShift is pressed : " + Key.isDown(Key.SHIFT);

}

  1. Now publish this FLA to SWF and HTML. Open the html file in FF and IE
  2. Try pressing SHIFT + TAB
  3. Verify Result 1.
  4. Now open the FLA and set wmode to “transparent windowless” and then publish
  5. Refresh the pages in IE and FF.
  6. Try pressing SHIFT + TAB
  7. Verify Result 2.

Actual Results:

  1. You’ll see both the browser pages trace Shift is pressed :true
  2. FF traces Shift is pressed :false and IE traces Shift is pressed :true

Expected results:

Both IE and FF should trace Shift is pressed :true at step 8.

Bad bad bad bad bad bad bad bad (read it like how Mallory says ;o) )

Work around: ( I hate this part)

Make a keyListener object in the root level(or anywhere you need it) of ur SWF and onKeyDown check if SHIFT is pressed and toggle a variable to true. on KeyUp, toggle it back to false. And everytime u want to do a Key.isDown (Key.SHIFT), check ur variable instead.

Doh!

Post a Comment