trial Posted August 12, 2018 Share Posted August 12, 2018 Hi, I manage to figure out how to tween a button's alpha from 1 to 0.5, using tweenjs. Now I can't seem to get it to jump to a certain location after the alpha is 0.5: this.coverBtn.addEventListener("click", coverBtnfadeOutClick.bind(this)); function coverBtnfadeOutClick() { createjs.Tween.get(this.coverBtn) .to({ alpha: 0.5 }, 100, createjs.Ease.none); if (this.coverBtn.alpha == 0.5) { this.coverBtn.x += 100; } } I usually just use onEnterFrame for AS2 in Flash era. How do I do that for html5? Quote Link to comment Share on other sites More sharing options...
bryangalli Posted September 26, 2018 Share Posted September 26, 2018 Looks like your if statement isn't waiting until your tween has completed. So, the script calls tween, then immediately calls the if statement without pausing to wait until the tween has completed.. thus this.coverBtn.alpha is not equal to 0.5 so the coordinate shift doesn't happen. You need a callback or in this case 'onComplete' event. Example of onComplete event binding here: https://www.createjs.com/docs/tweenjs/modules/TweenJS.html Cheers! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.