_alpha == 0 vs. _visible == false

Sometimes you make discoveries that change your world…

I made one tonight. Working on my new Flash portfolio, I’ve got a moving background on which they were small menus.

Each menu were triggered by a button. When clicking on them, the menu changed from alpha : 0 to alpha : 100.

My discovery is the following :

The Flash engine make a MAJOR difference between an object with an _alpha == 0 and an object _visible == false.

If an object has an alpha not equal to 100, the engine calculate thru a graphic routine what has to be shown. In the case of an object hidden, he don’t take it in consideration.

Check these two examples. Each swf has the same FPS (12) - I swear ! Oh and btw, this is only an example, my portfolio is not completed.

http://www.bellesfessescity.com/dump_laurent/portfolio/portfolio_alpha.html
Slow, specially on a low-end computer.

http://www.bellesfessescity.com/dump_laurent/portfolio/portfolio_visible.html
Look at the difference !

Morale : instead of putting your object at alpha 0, put them hidden. :slight_smile:

That’s true! That is one of the reasons why the mods are cracking down on Flash footers I guess. _alpha’s between 100 and 0 take a “notable” amount of computer memory even though the file size of the SWF is very small. Sometimes even scripts drains a lot of memory that simple large file tweens.

Well both run at the same speed for me, but you are right, _alpha clips (especiall when in motion and in multiple numbers) can be CPU intensive.

But you wanna know another reasing _visible = false is better than _alpha = 0?

Simple… on a monitor that is set to 16bit colors, _alpha=0 objects can still be seen… because they still exist. But if you _visible = false it, it hides it from the stage, which saves CPU resources… even if it is a tiny bit.