How do I detect mouse direction and change frame?
Hi there,
I'm building a simple 360 degree image rotation effect using single frames and forward and back buttons. I'm new to AS3 and have managed to create functioning buttons... (so my code may be a bit odd!)
But now I also want to advance frames by clicking and dragging on the image itself (or on an invisible button sat on top of the image).
Although there are some threads here which have asked the same thing, I don't understand how they were answered. My code is below, and the file I am practising with is on:
https://download.yousendit.com/MVNjeFlWSWh6NE4zZUE9PQ
At the moment if you click on the image area it will advance but as there is no code detecting mouse direction, it just goes forward. Can anyone help me understand how to implement a simple direction detection and then use this to decided whether to advance or go backwards....thank you!!
stop();
// advance 1 frame on click
function forward(e:MouseEvent):void {
if (currentFrame ==15) {
gotoAndStop(1);
}else{
gotoAndStop(currentFrame + 1);
}
}
// go back 1 frame on click
function back(e:MouseEvent):void {
if (currentFrame ==1) {
gotoAndStop(15);
}else{
gotoAndStop(currentFrame - 1);
}
}
btn_fwd.addEventListener(MouseEvent.CLICK, forward);
btn_bck.addEventListener(MouseEvent.CLICK, back);
// change frame on mouse direction???
function MouseMove(event:MouseEvent):void {
{
if(event.buttonDown==true)
if (currentFrame ==15) {
gotoAndStop(1);
}else{
gotoAndStop(currentFrame + 1);
}
}
}
stage_btn.addEventListener(MouseEvent.MOUSE_MOVE, MouseMove);
