AVM2 Performance – Sprite Alpha vs. Fill Alpha

Consider a black box with 50% opacity. A sprite with a black rectangular fill in it.

Which would render quicker?

  1. A sprite where the black fill has 50% alpha (0.5)
  2. A sprite with 50% alpha containing a solid fill

Anyone done any tests?

Posted in Questions | Tagged , , , | 2 Comments
  • Rigard

    Well doing something along these lines and changing the values of the fill and the sprite alpha didn’t give me a significant time difference between the two.

    [code]
    var time:Number = getTimer();
    trace(time);

    for (var i:uint = 0; i < 1000; i++) {
    var spr:Sprite = new Sprite();
    spr.graphics.beginFill(0x000000, .5);
    spr.graphics.drawRect(0, 0, 100, 100);
    spr.graphics.endFill();
    //spr.alpha = 1;
    addChild(spr);
    }

    time = getTimer();
    trace(time);
    [/code]

    You got some other kind of rendering in mind – over bitmaps or something like that? Or maybe while they’re moving. I don’t think it makes much difference.

  • Rigard

    Well doing something along these lines and changing the values of the fill and the sprite alpha didn't give me a significant time difference between the two.

    [code]
    var time:Number = getTimer();
    trace(time);

    for (var i:uint = 0; i < 1000; i++) {
    var spr:Sprite = new Sprite();
    spr.graphics.beginFill(0x000000, .5);
    spr.graphics.drawRect(0, 0, 100, 100);
    spr.graphics.endFill();
    //spr.alpha = 1;
    addChild(spr);
    }

    time = getTimer();
    trace(time);
    [/code]

    You got some other kind of rendering in mind – over bitmaps or something like that? Or maybe while they're moving. I don't think it makes much difference.