Jump to content
Search Community

Calling a method in another Typescript class with tl.call()

Thomas James Thorstensson
Moderator Tag

Go to solution Solved by Thomas James Thorstensson,

Recommended Posts

Thomas James Thorstensson
Posted

Hello fellow Greensockers!

 

Here is my little question.

 

I'm calling an instance method of a Typescript class from my class Banner.ts

.call(this.imageTiler.doFadeOut,[1], 3);

 

In ImageTiler class I have

doFadeOut(imgIndex) {
this.tileCreatorArr[imgIndex-1].doFadeOut();
}

 

Now of course, ''this" in ImageTiler will refer to the Tween I'm calling from in Banner.ts, so the tileCreatorArr is undefined. How do I best bind this up so that I can call doFadeOut and get this to refer to ImageTiler class ?

 

Thanks in Advance ?

 

 "S"

  • Solution
Thomas James Thorstensson
Posted
44 minutes ago, Thomas James Thorstensson said:

Hello fellow Greensockers!

 

Here is my little question.

 

I'm calling an instance method of a Typescript class from my class Banner.ts

.call(this.imageTiler.doFadeOut,[1], 3);

 

In ImageTiler class I have

doFadeOut(imgIndex) {
this.tileCreatorArr[imgIndex-1].doFadeOut();
}

 

Now of course, ''this" in ImageTiler will refer to the Tween I'm calling from in Banner.ts, so the tileCreatorArr is undefined. How do I best bind this up so that I can call doFadeOut and get this to refer to ImageTiler class ?

 

Thanks in Advance ?

 

 "S"

 

Replying to myself here as I found the solution I think. The below works ?

 

.call(() => {
this.imageTiler.doFadeOut(1) //Call the fit function again as action box size is variable and brand area may have been re-sized/hidden
},[1], 3)
  • Like 1
Posted

Hi,

 

Great to hear that you got it working and thanks for sharing your solution! ?

Hopefully more users will benefit from this.

 

Happy Tweening!

  • Thanks 1

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