Using the Wiimote buttons in Flash
WiiNintendo.net has posted a list of key codes that the various buttons on the Wiimote generate, stating that they work in Flash and JavaScript. Well, that's half accurate: They do work in JavaScript but not in Flash. Adding a Key listener in Flash doesn't register anything when the buttons on the Wiimote are pressed.
My first thought was to use the Flash/JavaScript Integration Kit (since the player in the Wii is version 7, we can't use ExternalInterface) to relay the key events that the buttons generate from JavaScript to Flash. Easier said than done.
After some fiddling, I got the key codes to transfer to Flash but there are three show stoppers with this method:
First and foremost, it doesn't work when the Flash movie has focus. I tried every method I know of capturing events in JavaScript and none of them results in the JavaScript event handler being called when the Flash movie has focus and a key is pressed.)
Secondly, you cannot have a full screen Flash movie and use this method due to the way Flashjs works (it creates embeds a new SWF every time you call a method in Flash and passes the uid, method to call and its arguments as FlashVars to it. This SWF then uses the uid and LocalConnection to talk to your actual SWF.) So if your actual SWF takes up the whole screen, this additional SWF will result in a vertical scroll arrow displaying on the Wii.
Finally, even if the first two show stoppers could somehow be resolved, when the Flash/JS communication does work (i.e., when the page has focus), there is lag that would probably be unacceptable for games and even for interface items.
Also, the list of key codes given in the WiiNintendo.net article has two typos. The A button has a key code of 13, not 170 and the 2 button has a key code of 173, not 17. So the actual list of key codes for the Wiimote is:
↑ 175 ↓ 176 → 177 ← 178 A 13 B 171 - 170 + 174 1 172 2 173
The next thing I'm going to try is plain old SetVariable. But first a bout of tennis on the Wii with Dave! :) If anyone has other ideas, I'm all ears. Please leave a note in the comments.
Update: So the tennis game can wait: SetVariable doesn't work on the Wii. Damn.
OK, so maybe I can use FSCommand to poll the JavaScript instead... *Doh!* Of course, I can't because functions called from FSCommand can't return values.
OK, so that's it from me. Ideas?
How about: Nintendo, please implement Key events for the Wiimote controller buttons like there are in JavaScript. Pretty please?
Comments
by Jon B on 2006-12-28 22:57:54
by BrokenBlog » Blog Archive » Wii Flash: The d-pad and buttons work! on 2006-12-28 23:04:56
by aral on 2006-12-29 12:04:32
by John Giotta on 2006-12-29 15:25:57
by Richard Leggett on 2006-12-29 16:28:23
by aral on 2006-12-29 17:00:44
by Richard Leggett on 2006-12-30 00:47:09
by alkmie on 2006-12-31 13:41:33
by Mario Klingemann on 2007-01-01 16:46:30
by The understated genius of my friend, Mario! at Aral Balkan on 2007-01-01 18:22:12
by Monopolio Podcast .... el podcast más demandado on 2007-01-01 19:27:13
by Kevin on 2007-01-02 18:57:42
by aral on 2007-01-03 16:04:36
by Matthieu on 2007-01-05 08:57:46
by WiiOpera @ Wiki (PukiWiki/TrackBack 0.3) on 2007-01-07 00:01:28
by Codebase » Blog Archive » Wii Flash on 2007-01-09 18:36:08
by Adam on 2007-01-29 10:33:14
by aral on 2007-01-29 11:14:39
by zharzone on 2007-02-07 20:32:06
by frankie on 2007-02-18 21:31:20
by Nobien » Blog Archive » Flash + Wii? on 2007-02-27 12:04:13
by flash platform! {desktop, mobile, touch screen…} on 2007-03-22 09:29:54
by sweblog » Blog Archive » WiiFlash Beta on 2007-04-06 08:20:29
by sweblog » Blog Archive » WiiFlash Release on 2007-04-07 05:34:04
by blog aggregatore programmazione flash » Blog Archive » Other links for Wii and Flash on 2007-04-18 07:28:21
by Matt on 2007-04-28 13:39:38
by Creattica - Flash » Blog Archive » Playing Flash on the Wii on 2007-05-02 10:52:07
by WiiOpera @ Wiki (PukiWiki/TrackBack 0.3) on 2007-05-04 22:34:05
by Hackszine.com on 2007-06-21 03:42:22
by 鲸男与互动新媒体/Interactive » Blog Archive » ??wiimote?nunchck??? on 2007-06-21 17:50:28
by dvanex on 2007-07-13 04:51:02
by Aral on 2007-07-13 08:36:32
by Chris on 2007-09-07 22:35:42
by 欢迎wiimote和nunchck两兄弟 于 鲸男与互动新媒体 on 2007-10-14 15:43:54
by gautam on 2008-12-25 12:34:04
by WiiFlash Release « sweblog · Blog von Sebastian Weyrauch on 2009-02-16 15:22:11
by Classroom ICT - The Wii | Digital Ether on 2009-06-21 06:01:03
by PittMFUG » Blog Archive » Writing Flash for the Nintendo Wii on 2009-07-26 20:40:28
by Jacob on 2010-01-01 07:58:12
by mr m. on 2011-05-17 00:13:52
by waterproof iphone 4 on 2012-07-26 00:37:35