Jump to content
Search Community

Help with pause

retropunk test
Moderator Tag

Recommended Posts

Hey guys, been a while!

 

I am using a snippet of code from SnorklTV's infinite scroller along with Greensock of course and I am trying to implement a pause function when the user rolls their mouse in and out of focus of the Flash.

I have the detection working but I am not sure how to pause the Tweens.

 

Do I need to wrap this into a Timeline?

 

Any ideas? Thanks!

 

var isPaused:Boolean;

this.stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseOn);
this.stage.addEventListener(Event.MOUSE_LEAVE, mouseOff);

function mouseOn(evt:MouseEvent):void {
this.stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseOn);
traceText.text = "mouse on the stage";
isPaused = true;
}
function mouseOff(evt:Event):void {
this.stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseOn);
traceText.text = "mouse off the stage";
isPaused = false;
}

function scrollIt() {
TweenMax.to(parent_mc, 1, {x:String(distanceToScroll), onComplete:resetDelay});
for each (var mc in parent_mc) {
	if (mc.x <= -395) {
		mc.x +=  lastItemX;
	}
}
}

function resetDelay() {
TweenLite.delayedCall( 1, reset );
}

function reset() {
for each (var mc in parent_mc) {
	mc.x +=  distanceToScroll;
}
parent_mc.x = startX;
TweenLite.delayedCall(1, scrollIt);
}

TweenLite.delayedCall( 1, scrollIt );

Link to comment
Share on other sites

hi retropunk,

 

Try

 

function resetDelay() {

if(isPaused == false){ 
    TweenLite.delayedCall( 1, reset );
    }

}

 

 

-----

 

from looking at your code shouldn't

 

isPaused be true for mouseOff and

isPaused be false for MouseOn?

 

when you detect that it should start moving again just call

 

reset();

 

------------

 

if the scroller is mid-tween when you rolloff it will finish the tween, but it won't tween/reset again until you tell it to with reset()

 

-------------

 

it might get wonky if the user rolls off / on quickly and repeatedly, not sure. test it out. let me know how it goes. if you run into trouble attach your files.

 

thx

 

Carl

Link to comment
Share on other sites

Hey Carl , yeah I tried exactly what you suggested already but the reset goes crazy if you roll off an on a couple of times.

It's fine that the tween finishes if it has already started but I need to interrupt the delays inbetween.

 

I'm gonna try and implement TimelineMax into this scenario. I think thats my best bet.

If I run into a problem with that I'll post again

 

I'll post my solution later. I think this rotator I am working on will be useful for other people. I am also building a nav so you can skip to any slide in the array of movieclips.

 

Thanks for responding so fast!

Link to comment
Share on other sites

oh nice! I didn't even think of that! Thanks!

The reason I did it the reverse way is because in the example I have there are panels with info on them. So when someone rolls over the flash the animation will pause so they can read the slide.

Then when the roll out the animation will continue. Check out my file, you'll see what I mean. Either way your solution seems perfect.

 

Check out my solution so far.

http://retropunk.com/files/Carousel-Microsite.zip

 

This is still a prototype but I am trying to get the scroller to be as dynamic as possible but fairly easy to update (xml, external files etc).

I also need to figure out how to use a small nav (4 little white boxes) to be able to jump gracefully from slide to slide....tricky!

I've done this in the past plenty of times but not using Greensock. I've been wanting to use TimelineMax and I'll make any excuse to learn the Greensock libraries more!

You're infinite scroller gave me the idea to give it a try so thanks!

 

Let me know what you think.

Link to comment
Share on other sites

that looks really nice.

 

i think adding navigation to a particular slide will be a bit of a challenge as they are constantly re-positioning themselves. I guess you could figure out the x of the requested slide and then tween the parent so that the proper slide shows up

 

c

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...