Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Help with MouseWheel function

New Here ,
Jun 22, 2012 Jun 22, 2012


Hi,

I am a relative newcomer to Flash,

I am trying to link blur and opacity to mousewheel interaction.

I have created a custom cursor, I would like to:

1) when wheel is scrolled up increase opacity to 100% and decrease blur to 0

2) when wheel is scrolled down decrease opacity to 0 and increase blur to 100%

Any help would be much appreciated:

[AS]

import flash.display.Sprite;

import flash.display.StageAlign;

import flash.display.StageScaleMode;

import flash.events.Event;

import flash.events.MouseEvent;

var myCursor:Sprite;

stage.align = StageAlign.TOP_LEFT;

stage.scaleMode = StageScaleMode.NO_SCALE;

function init()

{

          Mouse.hide();

          // this creates an instance of the library MovieClip with the

          // name, "MyCursorClass".  this contains your mouse cursor art

          //

          myCursor = new MyCursorClass();

          myCursor.mouseEnabled = false;

          myCursor.visible = false;

 

          // you'll want to make sure the child is added above everything

          // else, possibly in its own container

          //

          addChild(myCursor);

 

          // respond to mouse move events

          stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);

          stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveHandler);

}

function mouseMoveHandler(evt:MouseEvent):void

{

          // whenever the mouse moves, place the cursor in the same spot

          myCursor.visible = true;

          myCursor.x = evt.stageX;

          myCursor.y = evt.stageY;

}

function mouseLeaveHandler(evt:Event):void

{

          myCursor.visible = false;

}

init();

[/AS]

TOPICS
ActionScript
824
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 22, 2012 Jun 22, 2012

:

import flash.filters.BlurFilter;

// adjust this

var speed:Number = 1;

var bf:BlurFilter = new BlurFilter();

function mouseWheelF(e:MouseEvent) {

bf.blurX = bf.blurY -= speed*e.delta;

myCursor.filters = [bf];

myCursor.alpha +=speed*e.delta/100;

}

stage.addEventListener(MouseEvent.MOUSE_WHEEL,mouseWheelF);

Translate
Community Expert ,
Jun 22, 2012 Jun 22, 2012

:

import flash.filters.BlurFilter;

// adjust this

var speed:Number = 1;

var bf:BlurFilter = new BlurFilter();

function mouseWheelF(e:MouseEvent) {

bf.blurX = bf.blurY -= speed*e.delta;

myCursor.filters = [bf];

myCursor.alpha +=speed*e.delta/100;

}

stage.addEventListener(MouseEvent.MOUSE_WHEEL,mouseWheelF);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 22, 2012 Jun 22, 2012

Thankyou so much..

Exactly what I needed!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 22, 2012 Jun 22, 2012
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines