[web] Flash Mouse Issue

Started by
6 comments, last by RegularKid 14 years, 3 months ago
Hi, I'm currently writing a first person shooter in Flash ( AS3 ) and would like to be able to use the mouse for looking around. Obviously this doesn't work well right off the bat because Flash only picks up mouse movement when the mouse is over the Flash object. And there doesn't seem to be a way in AS3 to set the user's mouse position. However, I've seen FPS games done in a browser using Shockwave and something called an "xtra" plugin to be able to set the position of the user's mouse ( the one I saw was here: http://www2.rasterwerks.com/game/phosphor/beta2.asp ). So, the game is able to reset the mouse to the center of the screen each frame so that the user's mouse is always inside the Shockwave region allowing them to move the mouse all they want. Anyone have any ideas on how I might be able to do this in Flash / AS3? I'm guessing it'll have to be very creative if it's possible. Maybe use some sort of hybrid with Shockwave handling the input and passing it to the Flash app? Maybe there's something I can do in another language ( Java, &#106avascript ) and then pass the input information to the Flash app? Maybe there's something I'm not seeing in AS3 itself which would make this possible? Any ideas at all would be helpful, no matter how crazy or compilcated....I really want mouse look Thanks in advance!
Advertisement
You cant do that in Flash, for security reasons.

Its a good thing too. Imagine if all those shitty Flash ads all over the web were allowed to steal your mouse cursor, effectively forcing you to click on them?

There may be another plug-in or something that lets you get around this. But I wouldn't download it.
Quote:Original post by AndreTheGiant
You cant do that in Flash, for security reasons.

Its a good thing too. Imagine if all those shitty Flash ads all over the web were allowed to steal your mouse cursor, effectively forcing you to click on them?

There may be another plug-in or something that lets you get around this. But I wouldn't download it.


+1

It's bad enough already that flash steals mouse/keyboard focus without manually clicking on the embedded object. Allowing a random, unverified, remote application to control your mouse pointer would be insane.

[OpenTK: C# OpenGL 4.4, OpenGL ES 3.0 and OpenAL 1.1. Now with Linux/KMS support!]

Right, I totally agree that it would be bad if all the ads on the web could control your mouse. But it's definitely possible ( not in Flash ) to control the mouse ( see the FPS link in my original post ). I'm looking to do something like that ( even if it requires a seperate plugin or something ). I just can't see controlling an FPS with nothing but the keyboard. Too old-school and people are just too used to using the mouse to look around in an FPS.

So the idea would be to maybe have a 1x1 Java app somewhere on the page that does nothing but reposition the mouse each frame in the center of the Flash app. And of course Flash would need to be able to talk to said app in order to turn this functionality off ( for menus and what not ).

Is something like this possible?
Probably not. As you mentioned above, the other game achieves the functionality via an extra plugin that you need to install. If a user installs an extra plugin, it can do pretty much whatever it wants. But they're unlikely to want to do that. If Flash could do that, it probably wouldn't be installed so widely as it would be even more of a security risk.
Why not implement it this way:

When the mouse is in the dead center of the Flash window, The player is still. If the mouse is moved slightly to the left, the player slowly turns left. If the mouse is moved even further to the left, the player turns to the left faster. The further the mouse goes to the left, the faster the player turns. To the point where, just before the mouse leaves the left side of the Flash area, the player is spinning to the left at some high speed, say 5 spins per second. If the cursor actually leaves the Flash area, then pause the game. Do the same for Right, Top and Bottom. This way, the player will quickly learn to control the mouse cursor, and not move it too far from the center in any direction.

Think about how they implement 3D shooters on the WII. You cant move the pointer off your TV, yet you can still look in all directions by using a method similar to what I described.
Fair enough. I've never written a browser plugin before. Anyone know of a good beginners tutorial on the subject ( I don't know where to begin with all the results that came up in Google ).

Also, will I need to write a separate plugin for each browser ( IE, Firefox, Safari, etc. )? Or will one plugin work for all?

Would setting the mouse position be easy to do in a plugin?
Would my Flash app be able to turn this functionality on / off ( ie. be able to talk to the plugin )?
Quote:Original post by AndreTheGiant
Why not implement it this way:

When the mouse is in the dead center of the Flash window, The player is still. If the mouse is moved slightly to the left, the player slowly turns left. If the mouse is moved even further to the left, the player turns to the left faster. The further the mouse goes to the left, the faster the player turns. To the point where, just before the mouse leaves the left side of the Flash area, the player is spinning to the left at some high speed, say 5 spins per second. If the cursor actually leaves the Flash area, then pause the game. Do the same for Right, Top and Bottom. This way, the player will quickly learn to control the mouse cursor, and not move it too far from the center in any direction.

Think about how they implement 3D shooters on the WII. You cant move the pointer off your TV, yet you can still look in all directions by using a method similar to what I described.


Great idea! I'll definitely research some Wii shooters. I had thought of that originally ( haven't tried it yet ), but thought that it would feel strange. If the Wii can do it and it feels good, that's great news.

Thanks!

This topic is closed to new replies.

Advertisement