Oh just saw that post, but even if it is a bit shift of 24, why would that come into adding layer on layer... Guess we need to know more about adding colours to see if this is a flash bug or a digital colors in general issue but looking at mugtug and html5 - I'd fire at flash...
Below are solutions that work. Obviously there is no limitation per se.
Your methodology did not work because you redraw graphics for the same object. In order for alphas to stuck correctly one has to create new objects.
The most important thing to make it work is to set cacheAsBitmap to true or draw Bitmap. Both variations are presented below. If you change cacheAsBitmap to false it stops working.
With very low alpha (0.01) you will need to run more than 2000 loop iterations in order to make resulting transparency opaque. My hardware doesn't take it very well
Also, although it is not related to this topic, I noticed that you use MovieClip instances. MovieClip is much heavier than Sprite or Shape. So, for this kind of tests it is better to use Shape - it is the lightest. Even in general one should avoid MovieClip instances as much as possible. Sprite should be the most used DisplayObjectContainer.
So, here is code that extends your methodology.
This uses shapes directly with cacheAsBitmapset to true.
var rad:int = 10;
var s:Shape;
var rct:Shape = new Shape();
rct.graphics.beginFill(0xff0000);
rct.graphics.drawRect(0, 0, 100, 100);
addChild(rct);
rct.x = stage.stageWidth * .5 - 50;
rct.y = stage.stageHeight * .5 - 50;
container = new Sprite();
container.x = stage.stageWidth * .5;
container.y = stage.stageHeight * .5;
addChild(container);
var sTimer:Timer = new Timer(100, 1000);
sTimer.start();
sTimer.addEventListener(TimerEvent.TIMER, onTick);
function onTick(event:TimerEvent):void {
rad += 5;
s = new Shape();
s.cacheAsBitmap = true;
s.graphics.beginFill(0x000000, .02);
s.graphics.drawCircle(rad, rad, rad);
s.x = s.y = -rad;
container.addChild(s);
if (event.target.currentCount == 24) {
var label3:TextField = textField("24");
label3.x = 50;
label3.y = 100;
addChild(label3);
}
}
This one makes bitmap:
var rad:int = 10;
var s:Shape;
var rct:Shape = new Shape();
rct.graphics.beginFill(0xff0000);
rct.graphics.drawRect(0, 0, 100, 100);
addChild(rct);
rct.x = stage.stageWidth * .5 - 50;
rct.y = stage.stageHeight * .5 - 50;
container = new Sprite();
container.x = stage.stageWidth * .5;
container.y = stage.stageHeight * .5;
addChild(container);
var sTimer:Timer = new Timer(100, 1000);
sTimer.start();
sTimer.addEventListener(TimerEvent.TIMER, onTick);
function onTick(event:TimerEvent):void {
rad += 5;
s = new Shape();
s.graphics.beginFill(0x000000, .02);
s.graphics.drawCircle(rad, rad, rad);
var bmd:BitmapData = new BitmapData(s.width, s.height, true, 0x00000000);
bmd.draw(s);
var bm:Bitmap = new Bitmap(bmd);
bm.x = bm.y = -rad;
container.addChild(bm);
if (event.target.currentCount == 24) {
var label3:TextField = textField("24");
label3.x = 50;
label3.y = 100;
addChild(label3);
}
}