Jump to content
GreenSock

Thomas James Thorstensson

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

Go to solution Solved by Thomas James Thorstensson,

Recommended Posts

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"

Link to comment
Share on other sites

  • Solution
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
Link to comment
Share on other sites

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