# Rotating shapes in display container

**URL:** https://forum.kirupa.com/t/rotating-shapes-in-display-container/253956
**Category:** flash
**Created:** [March 6, 2008, 8:22pm UTC](https://forum.kirupa.com/t/rotating-shapes-in-display-container/253956 "2008-03-06T20:22:33Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![popfly](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@popfly](https://forum.kirupa.com/u/popfly)
#### Post date: [March 6, 2008, 8:22pm UTC](https://forum.kirupa.com/t/rotating-shapes-in-display-container/253956/1 "2008-03-06T20:22:33Z")

</div>

Howdy,

Flash CS3 - AS3  
Windows XP

I’m creating some rectangles dynamically and I’d like to rotate them each 180 degrees. The problem is, when I throw the rotation on them, it seems like they are rotating around the something else’s registration point. There has to be a simple explanation but this is driving me crazy.

**Desired result:** 10 rectangles are created and spaced out along one y value. They are also to be rotated 180 degrees each.

**Unwanted Current Result:** 10 rectangles are created and spaced out but they are rotated incorrectly

This chunk of code recreates the problem perfectly.

```auto
import flash.display.Sprite;
import flash.display.Graphics;
var barHolder:Array = new Array();
var barStage:Sprite = new Sprite();
addChild(barStage);
graph();

function graph() {
    for (var i:uint = 0; i<10; i++) {
        drawBox(10, 230, 5, 50, 5, i);
    }
    for (i=0; i<barStage.numChildren; i++) {
        barStage.getChildAt(i).rotation = 45;
    }
}
function drawBox(xval:int, yval:int, w:int, h:int, space:int, count:int):void {
    var myBar = new Shape();
    myBar.graphics.beginFill(0x000000);
    myBar.graphics.drawRect((xval*count) * space, yval, w, h);
    myBar.graphics.endFill();
    myBar.name = "bar"+count;
    //barHolder[count].rotation = 45;
    barStage.addChild(myBar);
}

```
