Jump to content

Setting alpha to 0 does not make movie clip transparent. Why?


terencechow
 Share

Recommended Posts

I'm using pixi v3.07

 

I have a movie clip for an initial state and a second one for a loop state. When I initiated the first movie clip I set visible = true and the second to false. 

 

I have an onComplete function for the first movie clip that `gotoAndPlay(0)` 's the second movie clip, which loops.

 

As the user scrolls down the page, I turn off the above 2 clips with visible = false.

 

The reason is because the sprite is offscreen and I want the movie clip to disappear and replay the first initial state when the person scrolls back up.

 

However I notice that when I turn off the 2 clips with visible= false. It doesn't disappear. Instead it just stops playing the sprite. I've tried setting dirty = true and alpha = 0 and worldAlpha = 0 but none of this works. The second movie clip is still visible.

 

Why is this? What am I doing wrong?

 

Thanks!

 

Terence

Link to comment
Share on other sites

Answering my own question.

 

Turns out alpha /visible works fine. I was using cancelAnimationFrame to cancel the animation after I made alpha = 0 / visible = false.

 

The reason it didn't work is because my animate function with requestAnimationFrame had the render function. Hence although I set the alpha to 0, I cancelled the animation, and it's alpha = 0 never got rendered.

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