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

AS3 MouseEvent Wheel Question

New Here ,
Jun 10, 2013 Jun 10, 2013

I have put a 3072 height Movie clip on the stage that I would like to scroll up and down on. Searching help I have came up with the code below:

import flash.events.MouseEvent;

function mouseWheel (event : MouseEvent):void {

          if ((event.delta < 0 && box_mc.y > 0 )||

                     (event.delta > 0 && box_mc.y < stage.stageHeight - box_mc.height)){

                              box_mc.y = box_mc.y + (event.delta * 2);

 

                    }

}

stage.addEventListener(MouseEvent.MOUSE_WHEEL,mouseWheel);

I will scroll down but not up. I was seeing about reversing this function but am lost on how to do so. How would I got about reversing this function so that I may mouse wheel up and mouse wheel down?

Where would I look in help to find if I was to scroll and have it ease into the mouse wheel event rather than just slowing moving without ease?

Thank you in advanced for any help and advice.

TOPICS
ActionScript
1.3K
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
Guru ,
Jun 12, 2013 Jun 12, 2013
LATEST

import flash.events.MouseEvent;

stage.addEventListener(MouseEvent.MOUSE_WHEEL, mouseWheel);

function mouseWheel(event:MouseEvent):void

{

    if (box_mc.y >= 0 && box_mc.y <= stage.stageHeight)

    {

        box_mc.y -=  event.delta;

    }

    else

    {

        if (box_mc.y < 0)

        {

            box_mc.y = 0;

        }

        else if (box_mc.y > stage.stageHeight)

        {

            box_mc.y = stage.stageHeight;

        }

    }

}

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