Jump to content

Search In
  • More options...
Find results that contain...
Find results in...

Project works with old version of GSAP but hangs with v12?

Recommended Posts

Hi there,

I have a big problem with a game I am making a sequel for. After much frustration I have found that I can fix the problem by reverting to an earlier version of the GSAP scripts.

The problem occurs when I try to perform many tweens or collision checks at once. The new Greensock gets stuck in a recursive loop. I think it might be something to do with having two tweens that run with an onUpdate function.

I know this probably isn't enough information yet but please could someone help me get to the bottom of this problem.


function checkHit(targetMc, pegNum){
	if(getDistance(ball._x, ball._y, targetMc._x, targetMc._y) <= collisionRadius){
		// Add 500 to score
		// Remove deleted peg from array
		aP.splice(pegNum, 1);
		// Do ball spin
		var hitAngle = getAngleOf(ball._x, ball._y, targetMc._x, targetMc._y);
		var useAngle = Math.abs(hitAngle);
		var rotateAngle:Number;
		if(useAngle <= 90){
			rotateAngle = Math.abs(useAngle-90)*-1;
		} else {
			rotateAngle = useAngle - 90;
		// Speed limiter
		if(currSpeed >= maxReboundSpeed){
			currSpeed = maxReboundSpeed;
		//// BONUS ////
		// Check long shot
		if(getDistance(ball._x, ball._y, storeBallPosX, storeBallPosY) > longShotDistance){
			drawBonus("longShot", targetMc._x, targetMc._y);
			storeBallPosX = ball._x;
			storeBallPosY = ball._y;
		// Multi Hit call
		if(hitsNoClicks >= 2){
			drawHitGraphics(targetMc._x, targetMc._y, hitsNoClicks);
		if(offTheWall == true){
			offTheWall = false;
			drawBonus("offTheWall", targetMc._x, targetMc._y)
		if(ballsHit == totalPegs){
			// Check if last ball hit
			gameStatus = "endOfLEvel";
			ball_splat._x = targetMc._x;
			ball_splat._y = targetMc._y;
			//nextLevel();  // now set by splat
			////// PEG HIT //////
		} else {
			// Do normal ball hit
			TweenMax.to(ball, 20, {physics2D:{velocity:currSpeed*0.85, angle:hitAngle - 180, gravity:gravity}, onUpdate:doChecks, motionBlur:{strength:mBStrength, quality:mBQuality}});
			TweenMax.to(ball, 5, {_rotation:(rotateAngle * 25), ease:Quad.easeOut, overwrite:false});
			// No smash every time
			var randExplode:Number = random (3) +1;
			targetMc.gotoAndPlay("explode_" + randExplode);

//// BORDER HIT /////

function checkBorders(){ 
		if(ball._x >= rightBorder - ballRadius){
		ball._x = (rightBorder - ballRadius) - edgeBuffer;
		offTheWall = true;
		//Bounce off
		TweenMax.to(ball, 20, {physics2D:{velocity:currXVelocity*0.7, angle:180, gravity:gravity}, onUpdate:doChecks, motionBlur:{strength:mBStrength, quality:mBQuality}});
		TweenMax.to(ball, 5, {_rotation:-wallBounceAmount, ease:Quad.easeOut, overwrite:false});
	} else if (ball._x <= leftBorder + ballRadius){
		ball._x = leftBorder + ballRadius + edgeBuffer;
		offTheWall = true;
		//Bounce off
		TweenMax.to(ball, 20, {physics2D:{velocity:currXVelocity*0.7, angle:0, gravity:gravity}, onUpdate:doChecks, motionBlur:{strength:mBStrength, quality:mBQuality}});
		TweenMax.to(ball, 5, {_rotation:wallBounceAmount, ease:Quad.easeOut, overwrite:false});
	if(ball._y >= bottomBorder - ballRadius){
		ball._y = bottomBorder - ballRadius - edgeBuffer;
		// Do death thing
		gameStatus = "gameover";
		delete onEnterFrame;

function doChecks(){
	for(i=0; i < aP.length; i++){
		checkHit(aP[i], i);

I think the problem code is in here somewhere. Thanks for any help you can give.
I'm not sure how to find out which greensock versions they both are.

Link to comment
Share on other sites

Hmm, nothing is jumping out at me as a clear cause of this issue. 


I would sooner guess that any migration issue would have to do with addition and/or removal of properties from the API.


For instance properties like time, currentProgress, duration are now methods time(), progress(), duration() (and others).


Doesn't appear that you are using any of those.


If there's any way you can zip and attach to the post (or privately send - just click on my profile) the files necessary to comile the game (or a portion of it) that works it would be most helpful in assessing what in v12 is causing the break. 

Link to comment
Share on other sites

Good News, 


I got your game to publish error free and run fine using v12 without making any changes.

The first time I tried renaming the com folders to switch versions i saw a slew of errors. 


If you compile with v11 and then change the com folder name to com_good and place a new com folder in there for v12, Flash gets really confused. 


Using Flash CS6 or higher go to Control > Clear Publish Cache and then re-export.




Copy your fla, all necessary scripts and the v12 com folder to a new folder, open up the fla and export.


Currently I have your fla successfully publishing using 


version 11.65 and 12.0.16


Let me know if the same works for you. 

Link to comment
Share on other sites

Hi there,

Really sorry, I had detailed what the problem was in the first PM but it got cut off when I sent it.
If you take the file you have got working and repeatedly click as fast as you can right up again the borders, making it bounce off the side repeatedly or occasionally bauble, the game goes into a recursion loop and breaks. 

I saw the problem you mentioned before but republishing it removed any errors.



Link to comment
Share on other sites

No worries, I think when I immediately saw the compile errors I just assumed that was the issue, and you did state that the issue was related to game-play above.


I tested the files and managed to get the recursion error to appear. Its very strange and not something that we've ever seen attributed to GSAP code. 


We'll take a deeper look and let you know what we find. 




BTW, I enjoyed playing the game. Its got nice mechanics and the concept is very original. 

Link to comment
Share on other sites

Hi Carl,

I had a thought last night that it could be something to do with the overwrite settings on the tweens. If two tweens get fired, both of which are running doChecks onUpdate, then I can see how that might break it as they are both running over each other. Not sure how to check this.

Were there any changes to the default overwrite settings between versions?


Link to comment
Share on other sites

Hi Will,


We found an issue in MotionBlurPlugin. Just sent you a PM with a zip. Thanks for your patience and for bringing this issue to our attention.



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.