Forum Topic: As: The Mouse Wheel

(3,487 views • 14 replies)

This topic is 1 page long.

<< < > >>
None

Inglor

Reply To Post Reply & Quote

Posted at: 7/23/05 06:55 AM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

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 ;)


None

Rustygames

Reply To Post Reply & Quote

Posted at: 7/23/05 07:50 AM

Rustygames LIGHT LEVEL 18

Sign-Up: 05/07/05

Posts: 6,662


None

liaaaam

Reply To Post Reply & Quote

Posted at: 7/23/05 07:57 AM

liaaaam NEUTRAL LEVEL 22

Sign-Up: 12/11/04

Posts: 14,536

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.


None

Incredible-Sausage

Reply To Post Reply & Quote

Posted at: 8/20/05 04:21 PM

Incredible-Sausage LIGHT LEVEL 06

Sign-Up: 06/24/05

Posts: 19

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.


None

mr-johnson22

Reply To Post Reply & Quote

Posted at: 8/20/05 04:31 PM

mr-johnson22 LIGHT LEVEL 15

Sign-Up: 07/16/05

Posts: 117

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


None

stickmoose

Reply To Post Reply & Quote

Posted at: 8/20/05 05:01 PM

stickmoose NEUTRAL LEVEL 19

Sign-Up: 03/10/03

Posts: 1,204

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.


None

fwe

Reply To Post Reply & Quote

Posted at: 8/20/05 05:51 PM

fwe DARK LEVEL 08

Sign-Up: 07/24/03

Posts: 3,361

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


None

orb

Reply To Post Reply & Quote

Posted at: 8/20/05 07:00 PM

orb EVIL LEVEL 17

Sign-Up: 05/01/03

Posts: 3,892

noice!

No more animated sigs. :(

BBS Signature

None

stickmoose

Reply To Post Reply & Quote

Posted at: 8/20/05 07:16 PM

stickmoose NEUTRAL LEVEL 19

Sign-Up: 03/10/03

Posts: 1,204

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.


None

ImpotentBoy2

Reply To Post Reply & Quote

Posted at: 8/20/05 09:02 PM

ImpotentBoy2 LIGHT LEVEL 18

Sign-Up: 04/01/03

Posts: 5,318

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

Some times my "L" key decides not to work.


None

stickmoose

Reply To Post Reply & Quote

Posted at: 8/20/05 09:17 PM

stickmoose NEUTRAL LEVEL 19

Sign-Up: 03/10/03

Posts: 1,204

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.


None

pumpkinlover

Reply To Post Reply & Quote

Posted at: 11/28/06 08:01 AM

pumpkinlover NEUTRAL LEVEL 02

Sign-Up: 08/13/04

Posts: 592

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

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


None

BillysProgrammer

Reply To Post Reply & Quote

Posted at: 9/24/08 09:35 PM

BillysProgrammer LIGHT LEVEL 16

Sign-Up: 09/17/08

Posts: 2,069

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


None

Blackfang

Reply To Post Reply & Quote

Posted at: 9/24/08 09:48 PM

Blackfang LIGHT LEVEL 21

Sign-Up: 08/27/05

Posts: 3,319

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


None

Musician

Reply To Post Reply & Quote

Posted at: 9/24/08 09:55 PM

Musician EVIL LEVEL 04

Sign-Up: 05/19/05

Posts: 2,199

At 9/24/08 09:48 PM, Blackfang wrote: INGLOR. WE MISSED YOU. Haha its actually really cool to see your name on the forums.

Read the date of the post.


All times are Eastern Standard Time (GMT -5) | Current Time: 01:16 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!