Jump to content
Search Community

Remember AdHelper.js? Issue with 'sleep' and 'wake'

Brandon Marsh test
Moderator Tag

Recommended Posts

Hello! My first post here, hopefully somebody can help. I'm doing some small banner work that includes AdHelper.js that Grant Skinner wrote a long time ago (See here: https://github.com/CreateJS/html5ads/tree/master/AdHelper) . I'm getting some errors on the following functions. Specifically, I'm getting errors for the following lines:

 

var originalFrame = ticker.frame; //record the original frame temporarily so we can revert

Error for above line:

Cannot read properties of undefined (reading 'frame')

 

It appears that when console.log'ing (ticker), that it's undefined. It looks like nothing should be 'wrong', and that it should be reading GSAP's .ticker, but I'm not sure why I'm getting undefined here. I know this code was definitely written a long time ago, so I have a suspicion that it's something small I'm doing wrong.

 

Not sure what the solution is here, but any help would be greatly appreciated. 

 

	p._sleep = function() {


		if (!this.awake) { return; }
		createjs.Ticker.paused = true;
		if (this.tickListener) { createjs.Ticker.removeEventListener("tick", this.tickListener); }
		window.TweenLite && TweenLite.ticker && TweenLite.ticker.sleep();
		this.dispatchEvent("sleep");
		this.awake = false;

	};

	p._wake = function() {
		if (this.awake) { return; }
		createjs.Ticker.paused = false;
		if (this.tickListener) { createjs.Ticker.addEventListener("tick", this.tickListener); }
	
		if (window.TweenLite) {
			var ticker = TweenLite.ticker;
			console.log(ticker);
			var originalFrame = ticker.frame; //record the original frame temporarily so we can revert
			ticker.frame = 1; //hack to make legacy versions of GSAP apply lag smoothing upon wake
			ticker.wake(true);
			ticker.frame = originalFrame;
		}

 

Link to comment
Share on other sites

Hi @Brandon Marsh. Welcome. 

 

Yeah, we definitely can't support AdHelper or troubleshoot code in another library that GreenSock didn't create. It looks like you're using TweenLite which is a relic from the very old GSAP - there's a much more modern syntax that does away with TweenLite/TweenMax/TimelineLite/TimelineMax. See

 

I suspect that maybe the problem is that the code is referencing TweenLite.ticker which should be gsap.ticker.

 

Good luck!

Link to comment
Share on other sites

Thanks Jack. No problem at all. I did try to change Tweenlite to gsap but still ran into the undefined error. I bet it has something to do with scope. Nevertheless it's not a world ending issue. I will do some digging and try to fix it, and if I do I will report back on here. 

 

Thanks for the quick reply.

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