How to use ctrlKey with mouse delta

Already using mouse delta wheel to change something, and I can't f

Page 1 of 1

2 Replies - 2392 Views - Last Post: 09 December 2009 - 12:18 PM

#1 DigitalMonk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 16-June 09

How to use ctrlKey with mouse delta

Posted 03 December 2009 - 10:14 AM

//mouse wheel delta code to adjust scroll speed
stage.addEventListener(MouseEvent.MOUSE_WHEEL,handleMouseWheel);
function handleMouseWheel(event:MouseEvent) {
	
		if (active&&event.delta>0) {
			scrollSpeed++;
		} else if (active&&event.delta < 0) {
			scrollSpeed--;
		}
	//}
}



Code above changes the scrolling speed of a text box. I would like to figure out how to combine the ctrlKey + MouseWheel to increase of decrease the font size.

From the Essential ActionScript 3.0 book by O'Reilly (pg. 563) and the CS4 help docs, it sounds like the ctrlKey state is already available and I just need to check for it by creating a listener. Then I would just need to add the conditions to the MouseEvent listener above. Is this correct?

OR..Do I need to create a var for the ctrlKey state and then check that var?

Thanks for the assist

Is This A Good Question/Topic? 0
  • +

Replies To: How to use ctrlKey with mouse delta

#2 Jason_Fields  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 14
  • Joined: 06-December 09

Re: How to use ctrlKey with mouse delta

Posted 06 December 2009 - 06:22 PM

look here for info on the AS3 mouseEvent class. There's a boolean value: ctrlKey that tells you whether the ctrl key is pressed. If I'm not mistaken, this is what you are looking for. You could do:
if(event.ctrlKey)
{
	 //code
}


This post has been edited by Jason_Fields: 06 December 2009 - 06:27 PM

Was This Post Helpful? 1
  • +
  • -

#3 DigitalMonk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 16-June 09

Re: How to use ctrlKey with mouse delta

Posted 09 December 2009 - 12:18 PM

View PostJason_Fields, on 6 Dec, 2009 - 05:22 PM, said:

look here for info on the AS3 mouseEvent class. There's a boolean value: ctrlKey that tells you whether the ctrl key is pressed. If I'm not mistaken, this is what you are looking for. You could do:
if(event.ctrlKey)
{
	 //code
}



Thanks for the assist Jason. Here's how I used it.

//mouse wheel delta code to adjust scroll speed and font size
stage.addEventListener(MouseEvent.MOUSE_WHEEL,handleMouseWheel);
function handleMouseWheel(event:MouseEvent) {
	
	if (event.ctrlKey&&active&&event.delta>0) {
		if (active==true&&oldTextSize.size!=130) {
			newTextSize.size = (oldTextSize.size + 10);
			oldTextSize.size=newTextSize.size;
			prompt_mc.prompt_txt.setTextFormat(newTextSize);
		}

	} else if ( event.ctrlKey && active && event.delta < 0 ) {
		
		if (active==true&&oldTextSize.size!=10) {
			newTextSize.size = (oldTextSize.size - 10);
			oldTextSize.size=newTextSize.size;
			prompt_mc.prompt_txt.setTextFormat(newTextSize);
		}
	}

	if (! event.ctrlKey&&active&&event.delta>0) {
		scrollSpeed++;
	} else if ( !event.ctrlKey && active && event.delta < 0 ) {
		scrollSpeed--;
	}
}


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1