00:00
00:00
Newgrounds Background Image Theme

Neptuno84 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

As: The Mouse Wheel

5,529 Views | 13 Replies
New Topic Respond to this Topic

As: The Mouse Wheel 2005-07-23 06:55:19


OMGZORS!!! AS MAIN!!! (;P)

a lot of advanced ASers don't know how to use the mouse wheel, it's a shame because it is really useful to use, this will explain the onMouseWheel handler

the first thing you need to do is create a new MouseListener ... this is done the following way

my_listener=new Object;
Mouse.addListener(my_listener);

now the next phase is actually add the onMouseWheel function, it is the part actually determining what happens

my_listener.onMouseWheel=function(delta){
//actions here
}

you're probebly wondering what "delta" is, delta is the amount of lines gone down, I'll just quote flash:

delta is an optional number indicating how many lines should be scrolled for each notch the user rolls the mouse wheel. A positive delta value indicates an upward scroll; a negative value indicates a downward scroll. Typical values are from 1 to 3; faster scrolling can produce larger values.

delta is very importent since it lets you know which direction has been scrolled... so right now you have

my_listener=new Object;
Mouse.addListener(my_listener);

my_listener.onMouseWheel=function(delta){
//actions here
}

actions here can depend on delta, for example you can increase or decrease the alpha of a movieclip depending on it allowing the user to see throught stuff, or better, zoom with a scripted camera (or without it) with it allowing users to "snipe" targets... this it very easially done

my_listener=new Object;
Mouse.addListener(my_listener);

my_listener.onMouseWheel=function(delta){
if((_root._xscale+delta<200) && (delta>0)){
_root._xscale+=delta;
_root._yscale+=delta;
}else if(_root._xscale-delta>50) && (delta<0)){
_root._xscale+=delta;
_root._yscale+=delta;
}
}

this can be scripted better , I know, so what :P

ask any questions ;)

Response to As: The Mouse Wheel 2005-07-23 07:50:01



- Matt, Rustyarcade.com

Response to As: The Mouse Wheel 2005-07-23 07:57:31


That's really awesome, good job. I had no idea you could use the mouse wheel in Flash, and I actually understand Delta (straight away! wow!).

Example.

Oh and I see it works better with a very high framerate. Very. High.


Sup, bitches :)

BBS Signature

Response to As: The Mouse Wheel 2005-08-20 16:21:33


At 7/23/05 07:57 AM, -liam- wrote: That's really awesome, good job. I had no idea you could use the mouse wheel in Flash, and I actually understand Delta (straight away! wow!).

Example.

Oh and I see it works better with a very high framerate. Very. High.

Lol, like the flash Liam. Add pictures! Jokes, i'm not that perverted.

Response to As: The Mouse Wheel 2005-08-20 16:31:11


How do you set a number for delta? Like, delta=3?

Response to As: The Mouse Wheel 2005-08-20 17:01:14


At 8/20/05 04:31 PM, mr_johnson22 wrote: How do you set a number for delta? Like, delta=3?

You don't set it. Delta is either 1 or -1, corresponding to the scroll movement.

Response to As: The Mouse Wheel 2005-08-20 17:51:59


At 8/20/05 05:01 PM, stickmoose wrote:
At 8/20/05 04:31 PM, mr_johnson22 wrote: How do you set a number for delta? Like, delta=3?
You don't set it. Delta is either 1 or -1, corresponding to the scroll movement.

Or more.. it can be -2 and 2


wtfbbqhax

Response to As: The Mouse Wheel 2005-08-20 19:00:26


noice!


No more animated sigs. :(

BBS Signature

Response to As: The Mouse Wheel 2005-08-20 19:16:17


At 8/20/05 05:51 PM, fwe wrote:
At 8/20/05 05:01 PM, stickmoose wrote:
At 8/20/05 04:31 PM, mr_johnson22 wrote: How do you set a number for delta? Like, delta=3?
You don't set it. Delta is either 1 or -1, corresponding to the scroll movement.
Or more.. it can be -2 and 2

Really? I never knew that.

Response to As: The Mouse Wheel 2005-08-20 21:02:54


my_listener=new Object;
Mouse.addListener(my_listener);
my_listener.onMouseWheel=function(delta){
if((_root._xscale+(delta*2)<200) && (delta*2>0)){
_root._xscale+=delta*2;
_root._yscale+=delta*2;
}else if(_root._xscale-delta>50) && (delta*2 <0)){
_root._xscale+=delta*2;
_root._yscale+=delta*2;
}
}
it can be any number

Response to As: The Mouse Wheel 2005-08-20 21:17:27


At 8/20/05 09:02 PM, ImpotentBoy2 wrote: my_listener=new Object;
Mouse.addListener(my_listener);
my_listener.onMouseWheel=function(delta){
if((_root._xscale+(delta*2)<200) && (delta*2>0)){
_root._xscale+=delta*2;
_root._yscale+=delta*2;
}else if(_root._xscale-delta>50) && (delta*2 <0)){
_root._xscale+=delta*2;
_root._yscale+=delta*2;
}
}
it can be any number

Yes, but delta in its original state is 1 or -1...how could it be over 1? Is it possible to scroll that fast? I thought onMouseWheel is invoked every scroll.

Response to As: The Mouse Wheel 2006-11-28 08:01:21


just found out (after a hour of messing with this thing) it doesnt work for mac.

so mac user.........BEWARE!

Response to As: The Mouse Wheel 2008-09-24 21:35:36


From your tutorial, I dont understand the last part, after you said using for sniping. U have stuff like if(_root._xscale < 200 = delta) BLAH BLAH, what does that stuff mean

Response to As: The Mouse Wheel 2008-09-24 21:48:29


INGLOR. WE MISSED YOU. Haha its actually really cool to see your name on the forums.