tags:

views:

13

answers:

0

Why is the red sprite not centered on the stage like the Spark Button? Is there some layout going on within the button that is not happening within the SpriteVisualElement?

package
{ 
 import flash.display.Sprite;

    import spark.components.Button;
    import spark.components.Group;
    import spark.core.SpriteVisualElement;

 public class MyGroup extends Group {

  public function MyGroup() {
   super();

   var container:SpriteVisualElement = new SpriteVisualElement();

   var s:Sprite = new Sprite();
   s.graphics.beginFill(0xFF0000);
   s.graphics.drawRect(0, 0, 250, 250);
   s.graphics.endFill();

   container.addChild(s);
   this.addElement(container);

   var btn:Button = new Button();
   btn.label = "Centered";
   this.addElement(btn);

   this.verticalCenter = 0;
   this.horizontalCenter = 0;

   // Why is the sprite (SpriteVisualElement) not centered on the stage?? The button is...
  }
 }
}