Discussion:
Place object in stage with alpha=0 (AS3)
(too old to reply)
Johnny Walker
2008-10-24 10:26:20 UTC
Permalink
Hi,

I want to place a movieclip in the stage but I want it to appear
transparent (alpha=0) and then fade it to opaque (alpha=1) to make it
appear slowly.

The problem is when I place the movieclip in the stage, the object is
visible for a brief moment before the next sentence that makes it
transparent is executed.

Here is part of the code:

addChild(_myMovieClip); //add my clip to the stage
_myMovieClip.alpha = 0; //make it transparent
TweenLite.to(_myMovieClip, 5, {alpha:1}); //fade it in

(TweenLite is a tweening engine that in this case changes the alpha
property of _myMovieClip from 0 to 1 in 5 seconds, but this I suppose is
irrelevant to the problem)

How can I solve this?
a***@rcc.yorkvilleu.ca
2012-11-12 20:12:16 UTC
Permalink
Post by Johnny Walker
Hi,
I want to place a movieclip in the stage but I want it to appear
transparent (alpha=0) and then fade it to opaque (alpha=1) to make it
appear slowly.
The problem is when I place the movieclip in the stage, the object is
visible for a brief moment before the next sentence that makes it
transparent is executed.
addChild(_myMovieClip); //add my clip to the stage
_myMovieClip.alpha = 0; //make it transparent
TweenLite.to(_myMovieClip, 5, {alpha:1}); //fade it in
(TweenLite is a tweening engine that in this case changes the alpha
property of _myMovieClip from 0 to 1 in 5 seconds, but this I suppose is
irrelevant to the problem)
How can I solve this?
Hey Johnny,

The problem your having is that your adding the object to the display list before you tell it that you want it to be transparent. The easiest way to fix this would just to move the alpha line above the addchild line, so it adds the child to display list after its alpha has been changed.

_myMovieClip.alpha = 0; //make it transparent
addChild(_myMovieClip); //add my clip to the stage

that way the object already has an alpha of 0 before being added into the display list. Hope this helped!
Continue reading on narkive:
Loading...