Skip to main content
added 396 characters in body
Source Link
Engineer
  • 30.4k
  • 4
  • 76
  • 124

Just addChild() each line into a new parent DisplayObject called square. Then rotate square instead of each of the children, individually. Flash will handle the correct rotation of the children therein.

Do this once:

var square:DisplayObject = new Sprite(); //Can't instantiate DisplayObject - it's abstract. So use Sprite.

//you'll need to get references to each of the lines used here (left to you):
square.addChild(black);
square.addChild(blue);
square.addChild(yellow);
square.addChild(red);

Do this every update:

if (leftPressed)
{
    square.rotation -= 90;
}

Just addChild() each line into a new parent DisplayObject called square. Then rotate square instead of each of the children, individually. Flash will handle the correct rotation of the children therein.

addChild() each line into a new parent DisplayObject called square. Then rotate square instead of each of the children, individually. Flash will handle the correct rotation of the children therein.

Do this once:

var square:DisplayObject = new Sprite(); //Can't instantiate DisplayObject - it's abstract. So use Sprite.

//you'll need to get references to each of the lines used here (left to you):
square.addChild(black);
square.addChild(blue);
square.addChild(yellow);
square.addChild(red);

Do this every update:

if (leftPressed)
{
    square.rotation -= 90;
}
Source Link
Engineer
  • 30.4k
  • 4
  • 76
  • 124

Just addChild() each line into a new parent DisplayObject called square. Then rotate square instead of each of the children, individually. Flash will handle the correct rotation of the children therein.