Be a Supporter!

As: The Mouse Wheel

  • 4,298 Views
  • 14 Replies
New Topic Respond to this Topic
Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
As: The Mouse Wheel Jul. 23rd, 2005 @ 06:55 AM Reply

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

Rustygames
Rustygames
  • Member since: May. 7, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to As: The Mouse Wheel Jul. 23rd, 2005 @ 07:50 AM Reply

heh heh http://www.newground../topic.php?id=310977

cheers


- Matt, Rustyarcade.com

liam
liam
  • Member since: Dec. 11, 2004
  • Offline.
Forum Stats
Member
Level 22
Blank Slate
Response to As: The Mouse Wheel Jul. 23rd, 2005 @ 07:57 AM Reply

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
Incredible-Sausage
Incredible-Sausage
  • Member since: Jun. 24, 2005
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to As: The Mouse Wheel Aug. 20th, 2005 @ 04:21 PM Reply

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.

mr-johnson22
mr-johnson22
  • Member since: Jul. 16, 2005
  • Offline.
Forum Stats
Supporter
Level 25
Game Developer
Response to As: The Mouse Wheel Aug. 20th, 2005 @ 04:31 PM Reply

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

stickmoose
stickmoose
  • Member since: Mar. 10, 2003
  • Offline.
Forum Stats
Member
Level 19
Blank Slate
Response to As: The Mouse Wheel Aug. 20th, 2005 @ 05:01 PM Reply

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.

fwe
fwe
  • Member since: Jul. 24, 2003
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to As: The Mouse Wheel Aug. 20th, 2005 @ 05:51 PM Reply

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

orb
orb
  • Member since: May. 1, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to As: The Mouse Wheel Aug. 20th, 2005 @ 07:00 PM Reply

noice!


No more animated sigs. :(

BBS Signature
stickmoose
stickmoose
  • Member since: Mar. 10, 2003
  • Offline.
Forum Stats
Member
Level 19
Blank Slate
Response to As: The Mouse Wheel Aug. 20th, 2005 @ 07:16 PM Reply

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.

GeoKureli
GeoKureli
  • Member since: Apr. 1, 2003
  • Offline.
Forum Stats
Supporter
Level 19
Game Developer
Response to As: The Mouse Wheel Aug. 20th, 2005 @ 09:02 PM Reply

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

stickmoose
stickmoose
  • Member since: Mar. 10, 2003
  • Offline.
Forum Stats
Member
Level 19
Blank Slate
Response to As: The Mouse Wheel Aug. 20th, 2005 @ 09:17 PM Reply

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.

pumpkinlover
pumpkinlover
  • Member since: Aug. 13, 2004
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to As: The Mouse Wheel Nov. 28th, 2006 @ 08:01 AM Reply

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

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

BillysProgrammer
BillysProgrammer
  • Member since: Sep. 17, 2008
  • Offline.
Forum Stats
Member
Level 16
Gamer
Response to As: The Mouse Wheel Sep. 24th, 2008 @ 09:35 PM Reply

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

Kool-Aid
Kool-Aid
  • Member since: Aug. 27, 2005
  • Offline.
Forum Stats
Member
Level 22
Game Developer
Response to As: The Mouse Wheel Sep. 24th, 2008 @ 09:48 PM Reply

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

Musician
Musician
  • Member since: May. 19, 2005
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to As: The Mouse Wheel Sep. 24th, 2008 @ 09:55 PM Reply

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.


I have no country to fight for; my country is the earth; I am a citizen of the world
-- Eugene Debs