I've read that if statements should be avoided in the shaders but I couldn't think of any other option, is there any better way to do this?

Edit: Also, this made me wonder... I had to create a separate programID that receives the alpha and uses it for the fading effect, but what am I supposed to do then if I have an object with a material type of Y (a specific shader) and I want to add this fading effect to it? (Like those effects of characters going stealth)

Am I supposed to create each of these effects plus an alternative version for the alpha effect?

Oh, and if instead of fading alpha you want to fade from white / black or to white or black, use a simple quad that covers your desired area and draw it on top.

Set the colors to white/black as desired and just tweak the alpha. A simple blend operation like EaseIn / EaseOut will give you even better results than linear blending. ActionScript tutorials are all over the place that will give you these easing equations.

And in the code I have a float[4] for the alphaChannel values (set to white, 1 in alpha), but when I change the alpha my quad is going blacker and blacker, but leaving the black quad on screen instead of disappearing, so I think I'm off something...

Edit: Ah, I also think it's relevant to mention that the texture already has an alpha value (though I manually set them all to 255) and I'm using:

This would work if I always had a black screen and want to fade in/out, but I'm trying to achieve the fade in/out with transparency (for example with a background image behind, and then an image fades in/out over it).