Skip to main content
July 19, 2009
Answered

MouseOver Scroll in actionscript 3

  • July 19, 2009
  • 1 reply
  • 4336 views

hi ppl,

im new to actionscript 3. I have some problems in creating mouseover scroll.

wat i want to do is to scroll the text (which was created as movie clip) when i mouse over on the button. and stop the scrolling when i mouse out.

thou i have some examples on how to make it work with actionscript 1 and 2, i dunno how to change it to actionscript 3.

so can u guys help me pls.

thanks alot in advance!

This topic has been closed for replies.
Correct answer Ned Murphy

There are a few ways you could approach this, so here's one.  All code goes in the timeline where the buttons live (on the actions layer).

The only thing I am uncertain of is what I did with the scrollV in the scrollUp and scrollDown functions.  I have not used this before, so I am assuming it is the same property that AS2 uses "scroll" for.

function scrollUp(evt:Event):void {
   textbox.scrollV += 1;
}

function scrollDown(evt:Event):void {
   textbox.scrollV -= 1;
}

function upOver(evt:MouseEvent):void {
    stage.addEventListener(Event.ENTER_FRAME, scrollUp);
}

up_btn.addEventListener(MouseEvent.ROLL_OVER, upOver);

function upOut(evt:MouseEvent):void {
    stage.removeEventListener(Event.ENTER_FRAME, scrollUp);
}

up_btn.addEventListener(MouseEvent.ROLL_OUT, upOut);

function downOver(evt:MouseEvent):void {
    stage.addEventListener(Event.ENTER_FRAME, scrollDown);
}

down_btn.addEventListener(MouseEvent.ROLL_OVER, downOver);

function downOut(evt:MouseEvent):void {
   stage.removeEventListener(Event.ENTER_FRAME, scrollDown);
}

down_btn.addEventListener(MouseEvent.ROLL_OUT, downOut);

1 reply

Ned Murphy
Legend
July 19, 2009

What to do you already have for code?

July 19, 2009

Hi ned murphy,

thanks for ur reply.

i only have codes which are in as 1.0 and 2.0.

the code below is under actions: Frame1...

moveup = new Boolean();
movedown = new Boolean();
up_btn.onRollOver = function() {
    moveup = true;
};
down_btn.onRollOver = function() {
    movedown = true;
};
up_btn.onRollOut = function() {
    moveup = false;
};
down_btn.onRollOut = function() {
    movedown = false;
};

this is the codes under text box movie clip..

onClipEvent (enterFrame) {
    if (_root.moveup == true) {
        textbox.scroll += 1;
    }
    if (_root.movedown == true) {
        textbox.scroll -= 1;
    }

}

but i dunno how to change them to as3.

thanks murphy!

Ned Murphy
Ned MurphyCorrect answer
Legend
July 19, 2009

There are a few ways you could approach this, so here's one.  All code goes in the timeline where the buttons live (on the actions layer).

The only thing I am uncertain of is what I did with the scrollV in the scrollUp and scrollDown functions.  I have not used this before, so I am assuming it is the same property that AS2 uses "scroll" for.

function scrollUp(evt:Event):void {
   textbox.scrollV += 1;
}

function scrollDown(evt:Event):void {
   textbox.scrollV -= 1;
}

function upOver(evt:MouseEvent):void {
    stage.addEventListener(Event.ENTER_FRAME, scrollUp);
}

up_btn.addEventListener(MouseEvent.ROLL_OVER, upOver);

function upOut(evt:MouseEvent):void {
    stage.removeEventListener(Event.ENTER_FRAME, scrollUp);
}

up_btn.addEventListener(MouseEvent.ROLL_OUT, upOut);

function downOver(evt:MouseEvent):void {
    stage.addEventListener(Event.ENTER_FRAME, scrollDown);
}

down_btn.addEventListener(MouseEvent.ROLL_OVER, downOver);

function downOut(evt:MouseEvent):void {
   stage.removeEventListener(Event.ENTER_FRAME, scrollDown);
}

down_btn.addEventListener(MouseEvent.ROLL_OUT, downOut);