PDA

View Full Version : scroll on mouse move



ptfury
June 17th, 2008, 12:05 PM
hey :)
i need to make a scroll while i move the mouse to left or right instead of using a bar or arrows.
how can i do this? :S

thanks :)

snickelfritz
June 17th, 2008, 01:14 PM
Here's something to start with using TweenMax for tweening and easing.
There are probably a dozen ways to do this trick.
Experiment.


import gs.TweenMax;

stage.addEventListener(MouseEvent.MOUSE_MOVE, scrollImage, false, 0, true);
function scrollImage(evt:MouseEvent):void {
if (mouseX < 50) {
TweenMax.to(image_mc, 10, {x:200, ease:Cubic.easeIn});
} else if (mouseX > 50) {
TweenMax.to(image_mc, 10, {x:-200, ease:Cubic.easeIn});
}
}

ptfury
June 18th, 2008, 06:49 AM
thanks, i was doing a much stupid way :P



function scrollPanel(event:Event):void
{
if (this.ca.scr.x<=0) {
this.ca.scr.x =0;
}
if (this.ca.scr.x>=-60) {
this.ca.scr.x =-60;
}

var xdist = mouseX-10;
this.ca.scr.x += Math.round(-xdist/2);
}