Jump to content
Search Community

TweenMax to repeat with dynamic different tweenmaxvars

isekream test
Moderator Tag

Recommended Posts

I'm trying to repeat a tween which on complete manipulates the original tween property

 

For example I'm tween a "y" position and on completing it repeating the tween but using the NEW "y" position. However, the repeat doesn't seem to work with dynamic properties...can you guys recommend me a correct way to do it?

Link to comment
Share on other sites

This is what I'm trying to do

public function spinning(){
		//var myTimeline:TimelineMax = new TimelineMax({onComplete:myFunction});
		for(var i:int = 0; i < 3; i++)
		{
			var sq:Loader = squares[i];
			TweenMax.to(sq, .2, {repeat:-1, y: sq.y, dynamicProps: {y: pos }, blurFilter:{blurY:20}, onComplete:function(sq){ if(sq.y > 176){ sq.y = -GUTTER - AREA; } },onCompleteParams:[sq]});
		}

	}

	public function pos(){
		return GUTTER +AREA;
	}

 

However I would rather repeat the Tween using new "y" position AFTER the tween is completed

Link to comment
Share on other sites

I'd probably do something more like this:

 

public function spinning(){
for (var i:int = 0; i 		var sq:Loader = squares[i];
	TweenMax.to(sq, .2, {dynamicProps: {y: pos }, blurFilter:{blurY:20}, onComplete:repeatSpin, onCompleteParams:[sq]});
}
}

public function repeatSpin(sq):void {
if (sq.y > 176) { 
	sq.y = -GUTTER - AREA;
}
TweenMax.to(sq, .2, {dynamicProps: {y: pos }, onComplete:repeatSpin, onCompleteParams:[sq]})
}

public function pos(){
 return GUTTER +AREA;
}

Link to comment
Share on other sites

Sounds like there must be something else going on in your code - I just tested this and it worked great for me even with a duration below 1. Could you please post a very simple FLA that demonstrates the problem so that I can publish it on my end and see the error? You are using the latest version of TweenMax, right?

Link to comment
Share on other sites

Apparently I was not and updated to the latest version.

 

In the end though your API could not produce the solutions I wanted.

 

I ended up having to use

public function spinning(e)
	{
		var max:Number = squares.length;

		// Get the last frame in the array
		var last:Loader = squares[max - 1];
		if(Math.floor(SPEED) <= 1){
			for(var j:Number = 0; j < max; j++)
			{

					if(Math.floor(squares[j].y) >= -1 && Math.floor(squares[j].y) <= 1){
						removeEventListener(Event.ENTER_FRAME,spinning);
						straighten(j);
					}


			}
			//
		}
		// If the last frame is below the stage height
		if(last.y >= 176 + GUTTER)
		{
			// Get reference to the first frame in the array
			var first:Loader = squares[0];

			// Set the last frame position just above the first one
			last.y = -AREA;

			// Take the reference from the end of the array
			var frame:Loader = Loader(squares.pop());

			// Now stick it on the front of the array so it's now the first one
			squares.unshift(frame);
		}

		// Now get the current last frame from the array and move it
		last = squares[max - 1];
		last.y += (SPEED -= (SPEED * 0.08));

		// Loop used to move each frame....here we start at the second to last one in the array
		// and iterate in descending order.  This is done because we are moving the last frame (see above)
		// and then all the other frames follow behind
		for(var i:Number = max - 2; i >= 0; i--)
		{
			// Get current frame from the array
			var current:Loader = squares[i];

			// Get the frame that is infront of the current frame
			var next:Loader = squares[i + 1];

			// Position current frame relative to the next one infront of it
			current.y = next.y - current.height - GUTTER;
		}
	}

 

in order to get the desired results. Just need to straighten out a few bugs

I am trying to create a slot machine effect using dynamically loaded movieclip

 

Can you offer up a way that I can integrate it using your API?

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