Flash ScrollPane Mouse Wheel Event

Getting the ScrollPane in flash to work with a mouse wheel can be tricky. It will not allow the mouse wheel to scroll if there is not actual content right underneath the mouse pointer. This can be cumbersome for dynamic content in the pane. To fix this, you can use the following AS3 code to scroll the ScrollPane without having to mess with background sizes in the pane.

// Listen for mouse wheel event on the stage to scroll content
stage.addEventListener( MouseEvent.MOUSE_WHEEL,
	function( event:MouseEvent ):void
	{
		if( scrollPane !== null )
		{
			scrollPane.verticalScrollPosition += - ( event.delta * 8 );
		}
	});

You can adjust the “( event.delta * 8 )” to only “event.delta” if you don’t want to change the amount of scrolling that is performed.