Working with the Stage : Stage : Development Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Development » Stage »

 

Working with the Stage


 

package{
  import flash.display.Sprite;
  import flash.display.Stage;
  import flash.display.StageAlign;
  import flash.display.StageScaleMode;
  import flash.display.DisplayObjectContainer;
  import flash.events.Event;

  public class Main extends Sprite
  {
         public function Main()
         {
                this.graphics.beginFill(0xff00001);
                this.graphics.drawRect(00, stage.stageWidth/2, stage.stageHeight/2);
                this.graphics.endFill();
                //set what part of the browser the stage will set itself in
                this.stage.align = StageAlign.TOP_LEFT;
                //set how the stage scales itself
                this.stage.scaleMode = StageScaleMode.NO_SCALE;
                //add an event listener for the stages resized event
                stage.addEventListener(Event.RESIZE, stageResized);

          }

         private function stageResized(event:Event):void
         {
                trace(stage.stageHeight+"  "+stage.stageWidth);

                this.graphics.clear();
                this.graphics.beginFill(0xff00001);
                this.graphics.drawRect(00, stage.stageWidth/2, stage.stageWidth/2);
                this.graphics.endFill();
        }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Development
» Stage