Jump to content
Search Community

stopping TweenMax @ certain point in rotaton

scottiescotsman test
Moderator Tag

Recommended Posts

function mouseOUT(e:MouseEvent):void{
	TweenMax.to(menu_MAIN, 2, {rotation:"360", ease:Linear.easeNone, repeat:-1});
}

function mouseOVER(e:MouseEvent):void{
	TweenMax.killTweensOf(menu_MAIN);;
}

Hi guys, here is a little problem I have and cant figure out how to solve it

 

say I have a clock hand @ 12 o'clock which rotates constantly until I MOUSE_OVER it,

 

what I am trying to do is when I MOUSE_OVER it I want the clock hand to always

 

stop @ 12 o'clock no mater when I MOUSE_OVER it.

 

 

 

 

 

Thanks for your help in advance

Steven

 

Link to comment
Share on other sites

if the 12 oclock position is where the menu starts you can just pause the tween at a time of 0 like

//create the tween outside your mouse functions
var clockTween = TweenMax.to(menu_MAIN, 2, {rotation:"360", ease:Linear.easeNone, repeat:-1});

function mouseOUT(e:MouseEvent):void{
clockTween.play();
}


function mouseOVER(e:MouseEvent):void{
clockTween.pause(0);
}

Does that work?

 

If not, please provide a simplified FLA that we can look at. Thanks.

Link to comment
Share on other sites

ok. 

 

here the basic idea is that you use an isHit boolean to track whether or not you have rolled over the spinning thing

 

import com.greensock.*;
import com.greensock.easing.*;


var isHit:Boolean = false;
var clockTween = TweenMax.to(menu_MAIN,2,{rotation:"360",ease:Linear.easeNone,onComplete:checkHit});


function mouseOUT(e:MouseEvent):void {
trace("mouse out");
isHit = false;
if (clockTween.progress() < 1) {
clockTween.resume();
} else {
clockTween.restart();
}
}




function mouseOVER(e:MouseEvent):void {
isHit = true;
}


function checkHit() {
if (! isHit) {
clockTween.restart();
}
}


menu_MAIN.addEventListener(MouseEvent.ROLL_OVER, mouseOVER);
menu_MAIN.addEventListener(MouseEvent.ROLL_OUT, mouseOUT);
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...