KeyHit Functions unresponsive in Flash

Monkey Forums/Monkey Bug Reports/KeyHit Functions unresponsive in Flash

KawaCoder(Posted 2012) [#1]
Some KeyHit() functions seem no effect on Flash app. I tried the app for both HTML5 and Flash. HTML5 version - no problem. Flash won't respond to the functions. In this case, I used KeyHit(KEY_SPACE) test in OnUpdate() method.















M


therevills(Posted 2012) [#2]
With Flash, most times you have to manually focus the flash player, try clicking on the player and seeing if your key hits work.


KawaCoder(Posted 2012) [#3]
Yes, it works once you click the app manually. Thanks a bunch. I'll have to remind my students to do so once the Flash app is launched.

It would be cooler if the app is automatically focused when launched.


therevills(Posted 2012) [#4]
No problem. Most Flash applications get around this by adding "Play" button on the first screen, forcing the user to click it and by doing so setting focus to the movie.

You can get IE to autofocus by changing MonkeyPro\targets\flash\MonkeyGame.html to look like this:

[monkeycode]
<html>

<head><title>Monkey Game!</title></head>

<body onLoad="window.document.MonkeyGame.focus();">

<embed name="MonkeyGame" src="MonkeyGame.swf" type="application/x-shockwave-flash" width="640" height="480" wmode="direct">
</embed>

</body>

</html>
[/monkeycode]

(remember to delete your build folder before compiling)

This doesnt work for Chrome...

I would just stick with a button, its easy and the safest way ;)


KawaCoder(Posted 2012) [#5]
Thanks, Steve, for the tip. I'll keep that in my Tips folder.

Right now, I am focusing on HTML5 platform for my current work, Monkey Console project.

Geo