Jump to content

How to move a button after tweening it's alpha?


trial
 Share

Recommended Posts

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?

Link to comment
Share on other sites

  • 1 month later...

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!

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...