Error Uncaught TypeError: Cannot read properties of undefined (reading 'tweenjs_count')

Participant ,
Jan 16, 2022 Jan 16, 2022

Copy link to clipboard

Copied

 

 

 

setTimeout(function () {
var photo2Sound = createjs.Sound.play("crocodile", { volume: 1 });
photo2Sound.on("complete", photoSoundCompleteHandler, this);
}, 2000);

 

Hi. I'm working with canvass. I get an error with the above code. I'm not sure what I am doing wrong. 

When the sound completes, I am trying to call the photoSoundComplete() function.

 

Uncaught TypeError: Cannot read properties of undefined (reading 'tweenjs_count')

 

Any help would be appreciated.

Thanks

Views

674

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Jan 17, 2022 Jan 17, 2022
So create a reference to the current timeline and send it as an argument of the on method inside of the setTimeout method. Like this: var _this = this; setTimeout(function () { var photo2Sound = createjs.Sound.play("crocodile", { volume: 1 }); photo2Sound.on("complete", photoSoundCompleteHandler, _this); // update here }, 2000); Regards, JC

Likes

Translate

Translate
Adobe Community Professional ,
Jan 16, 2022 Jan 16, 2022

Copy link to clipboard

Copied

Hi.

 

Here it worked without a problem.

 

Since the error refers to a property called tweenjs_count, are you sure it's not coming from somewhere else?

 

Please let us know.

 

Regards,

JC

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 16, 2022 Jan 16, 2022

Copy link to clipboard

Copied

Hi - I'm sorry. The error is a tween error which is called in 

photoSoundCompleteHandler

I use this tween for the target "king"

createjs.Tween.get(this.king, {override:true}).to({y:578}, 1000, createjs.Ease.bounceOut);

Then I play a sound. When it completes I call soundCompleteHandler to tween "king" back to another position.

It looks like there is a problem tweeting the same target. BUT I thought that override solved that,

function soundCompleteHandler ()
{
	createjs.Tween.get(this.king, {override:true}).to({y:1085}, 1000, createjs.Ease.bounceOut);
}

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 17, 2022 Jan 17, 2022

Copy link to clipboard

Copied

OK.  No problem.

 

I think it's a context problem.

 

If you run...

console.log(this.king);

 

... inside of the soundCompletHandler function, you will probably get undefined. Can you confirm this?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 17, 2022 Jan 17, 2022

Copy link to clipboard

Copied

Hi . yes, I got underfined

 

codeBeastAdobe_0-1642446335938.png

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 17, 2022 Jan 17, 2022

Copy link to clipboard

Copied

So create a reference to the current timeline and send it as an argument of the on method inside of the setTimeout method. Like this:

var _this = this;

setTimeout(function () {
var photo2Sound = createjs.Sound.play("crocodile", { volume: 1 });
photo2Sound.on("complete", photoSoundCompleteHandler, _this); // update here
}, 2000);

 

Regards,

JC

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 17, 2022 Jan 17, 2022

Copy link to clipboard

Copied

I love you Joao.

I spent days on that and it all looked perfect. I didn't realise that I had to create an reference for the timeline.

That is a massive help to me. THANK YOU.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 17, 2022 Jan 17, 2022

Copy link to clipboard

Copied

Awesome! You're welcome!

 

Don't worry. Context is very tricky in JavaScript.

 

Have a nice day!

 

Regards,

JC

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 12, 2022 May 12, 2022

Copy link to clipboard

Copied

LATEST

Praveen24425332bn1l_0-1652365495092.png

Hi Joao,

While loading the page, It is showing the error "the pagename property is undefined". But I had defined in adobe launch rule as in below mentioned screen shot as "pn = s.pageName". Even I had tried by clearing the cookie/ cache. But the error still exists. It is not resolved even refreshing the page. Please help me.

 

Praveen24425332bn1l_1-1652365613670.png

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines