WiiFlash Tip #1 – A virtual Wii-mouse

I’ve been doing a lot of really cool stuff with WiiFlash at the Bank – but I can’t really share any of the code. So, to help any aspiring WiiFlash developers out there, I’ll post a few tips over time with things that would have helped me out. If you don’t know anything about WiiFlash, take a look at their site, it’s a pretty cool hack. Now that I’ve got a good working class system, I just want to sit around and create mini-games.  I wish that I had the free time!

Tip #1 -Using the Wii Controller as a mouse in Flash

The toughest problem that I’ve come across so far: “how do you use the controller as a mouse (click on buttons) in a Flash movie without relying on WiiFlash’s crappy mousemode?”The “mousemode” feature takes over control of the system mouse pointer and uses the controller to point and click. I didn’t want this – I just wanted a nice Flash sprite moving around and still allow the user to click on things with their real mouse. But I wasn’t quite sure how to have this sprite fire off mouse events.

Solution: Senocular’s VirtualMouse class.

Once you’ve figured out how to read the IR points from a sensor bar (a future tip), and have a pointer moving around the screen, just set your virtual mouse instance’s X and Y values to the same as the pointer sprite. Trap the A button press event to fire off a virtual mouse CLICK event and that’s it! Well, I guess there are a few details to fill in still – but you get the general idea. Get it working properly and you can interact with your movie/game with the mouse and the Wii controller.