Search code examples
actionscript-3graphicsflashdevelop

How to adjust the z-axis, if there is, for graphics in AS3


I'm a beginner in FlashDevelop. I drew a simple circle. I also embedded a .jpg. Is there any way to place the circle I drew before the jpeg?

This is placed inside the init():

        [Embed (source = "images/Untitled.png")]
        var bg:Class;
        var bmp1:Bitmap = new bg;
        addChild(bmp1);
        var k:int, l:int;
            for (l = 0; l < 10; l++)
            {
                for (k = 0; k < 8; k++)
                {
                    graphics.beginFill(0xff0000, 1);
                    graphics.drawCircle(k*50, l*50, 10);
                    graphics.endFill();
                }
            }

enter image description here


Solution

  • [Embed (source = "images/Untitled.png")]
    var bg:Class;
    
    var bmp1:Bitmap = new bg;
    addChild(bmp1); // Add the bitmap first
    
    var sprite1:Sprite = new Sprite();
    this.addChild(sprite1); // Add the sprite afterwards; it appears on top of the bitmap
    
    var k:int, l:int;
    for (l = 0; l < 10; l++)
    {
        for (k = 0; k < 8; k++)
        {
            sprite1.graphics.beginFill(0xff0000, 1);
            sprite1.graphics.drawCircle(k*50, l*50, 10);
            sprite1.graphics.endFill();
        }
    }