Packagevegas.display
Classpublic class Background
InheritanceBackground Inheritance CoreSprite Inheritance flash.display.Sprite
Implements Directionable, Drawable
Subclasses CoreComponent, Cover, Protector

This display is used to create a background in your application or in an other display of the application.

Example :

     import vegas.display.Background ;
     
     import flash.display.GradientType ;
     import flash.display.StageAlign ;
     import flash.display.StageScaleMode ;
     
     import graphics.Direction ;
     import graphics.FillStyle ;
     import graphics.FillGradientStyle ;
     import graphics.LineStyle ;
     
     stage.align     = StageAlign.TOP_LEFT ;
     stage.scaleMode = StageScaleMode.NO_SCALE ;
     
     var background:Background = new Background( "background" ) ;
     
     background.lock() ; // lock the update method
     
     // background.topLeftRadius = 15 ;
     // background.bottomLeftRadius = 15 ;
     
     background.fill = new FillStyle( 0xD97BD0  ) ;
     // background.line = new LineStyle( 2, 0xFFFFFF ) ;
     background.w    = 400 ;
     background.h    = 300 ;
     
     background.unlock() ; // unlock the update method
     background.update() ; // force update
     
     // background.setSize( 740, 400 ) ;
     
     addChild( background ) ;
     
     var keyDown:Function = function( e:KeyboardEvent ):void
     {
         var code:uint = e.keyCode ;
         switch( code )
         {
             case Keyboard.SPACE :
             {
                 if( background.isFull )
                 {
                     background.autoSize = false ;
                     background.fill     = new FillStyle( 0xD97BD0 ) ;
                     background.isFull   = false ;
                 }
                 else
                 {
                     background.autoSize         = true ;
                     background.gradientRotation = 90 ;
                     background.useGradientBox   = true ;
                     background.fill             = new FillGradientStyle( GradientType.LINEAR, [0x071E2C,0x81C2ED], [1,1], [0,255] ) ;
                     background.isFull           = true ;
                     background.direction        = null ;
                 }
                 break ;
             }
             case Keyboard.UP :
             {
                 background.autoSize  = true ;
                 background.fill      = new FillStyle( 0x000000 ) ;
                 background.isFull    = true ;
                 background.direction = Direction.HORIZONTAL ;
                 break ;
             }
             case Keyboard.DOWN :
             {
                 background.autoSize  = true ;
                 background.fill      = new FillStyle( 0xFFFFFF ) ;
                 background.isFull    = true ;
                 background.direction = Direction.VERTICAL ;
                 break ;
             }
         }
     }
     
     stage.addEventListener( KeyboardEvent.KEY_DOWN , keyDown ) ;
     
     trace( "Press a key (DOWN, UP, SPACE) to change the view of the background." ) ;
     



Public Properties
 PropertyDefined By
  align : uint
The alignement of the background.
Background
  autoSize : Boolean
Indicates if the background is resizing when the stage resize event is invoked.
Background
  bottomLeftRadius : Number
The radius of the bottom-left corner, in pixels.
Background
  bottomRightRadius : Number
The radius of the bottom-right corner, in pixels.
Background
  direction : String
Indicates the direction value of the background when the display is in this "full" mode (default value is null).
Background
  fill : IFillStyle
Determinates the IFillStyle reference of this display.
Background
  gradientMatrix : Matrix
The matrix value to draw the gradient fill.
Background
  gradientRotation : Number = 0
The rotation value to draw the gradient fill.
Background
  gradientTranslation : Point
The translation vector to draw the gradient fill.
Background
  h : Number
Determinates the virtual height value of this component.
Background
  isFull : Boolean
Indicates if the background use full size (use Stage.stageWidth and Stage.stageHeight to resize the background).
Background
  line : ILineStyle
Determinates the ILineStyle reference of this display.
Background
 Inheritedlogger : Logger
Determinates the internal ILogger reference of this Logable object.
CoreSprite
  maxHeight : Number
This property defined the maximum height of this display.
Background
  maxWidth : Number
Defines the maximum width of this display.
Background
  minHeight : Number
This property defined the mimimun height of this display (This value is >= 0).
Background
  minWidth : Number
This property defined the mimimun width of this display (This value is >= 0).
Background
  topLeftRadius : Number
The radius of the upper-left corner, in pixels.
Background
  topRightRadius : Number
The radius of the upper-right corner, in pixels.
Background
  useGradientBox : Boolean
Indicates if the IFillStyle of this display use gradient box matrix (only if the IFillStyle is a FillGradientStyle).
Background
  w : Number
Determinates the virtual height value of this component.
Background
Public Methods
 MethodDefined By
  
Background(isFull:Boolean = false)
Creates a new Background instance.
Background
  
doLater():void
Launch an event with a delayed interval.
Background
  
draw(... arguments):void
Draw the display.
Background
  
initBackgroundPen(graphic:* = null):IPen
Init the pen to draw the background of this display.
Background
 Inherited
isLocked():Boolean
Returns true if the object is locked.
CoreSprite
 Inherited
lock():void
Locks the object.
CoreSprite
  
Notify an event when you resize the component.
Background
  
refresh(init:*):void
Refresh and initialize the display with a generic object and invoke the "update" method.
Background
 Inherited
resetLock():void
Reset the lock security of the display.
CoreSprite
  
resize(e:Event = null):void
Resize and update the background.
Background
  
setCornerRadius(n:Number):void
Defines all corner radius of the background (upper-left, upper-right, bottom-left and bottom-right).
Background
  
setSize(w:Number, h:Number):void
Sets the virtual width (w) and height (h) values of the component.
Background
 Inherited
unlock():void
Unlocks the display.
CoreSprite
  
update():void
Update the display.
Background
  
This method is invoked after the draw() method in the update() method.
Background
  
Invoked when the enabled property of the component change.
Background
  
viewResize():void
Invoked when the component is resized.
Background
Protected Methods
 MethodDefined By
 Inherited
addedToStage(e:Event = null):void
Invoked when the display is added to the stage.
CoreSprite
  
addedToStageResize(e:Event = null):void
Invoked when the display is removed from the stage to enable the autoSize mode.
Background
 Inherited
removedFromStage(e:Event = null):void
Invoked when the display is removed from the stage.
CoreSprite
  
removedFromStageResize(e:Event = null):void
Invoked when the display is removed from the stage to disable the autoSize mode.
Background
Property Detail
alignproperty
align:uint

The alignement of the background.


Implementation
    public function get align():uint
    public function set align(value:uint):void

See also

autoSizeproperty 
autoSize:Boolean

Indicates if the background is resizing when the stage resize event is invoked.


Implementation
    public function get autoSize():Boolean
    public function set autoSize(value:Boolean):void
bottomLeftRadiusproperty 
bottomLeftRadius:Number

The radius of the bottom-left corner, in pixels.


Implementation
    public function get bottomLeftRadius():Number
    public function set bottomLeftRadius(value:Number):void
bottomRightRadiusproperty 
bottomRightRadius:Number

The radius of the bottom-right corner, in pixels.


Implementation
    public function get bottomRightRadius():Number
    public function set bottomRightRadius(value:Number):void
directionproperty 
direction:String

Indicates the direction value of the background when the display is in this "full" mode (default value is null).


Implementation
    public function get direction():String
    public function set direction(value:String):void

See also

fillproperty 
fill:IFillStyle

Determinates the IFillStyle reference of this display.


Implementation
    public function get fill():IFillStyle
    public function set fill(value:IFillStyle):void
gradientMatrixproperty 
public var gradientMatrix:Matrix

The matrix value to draw the gradient fill. This property override the gradientRotation and gradientTranslation properties.

gradientRotationproperty 
public var gradientRotation:Number = 0

The rotation value to draw the gradient fill.

gradientTranslationproperty 
public var gradientTranslation:Point

The translation vector to draw the gradient fill.

hproperty 
h:Number

Determinates the virtual height value of this component.


Implementation
    public function get h():Number
    public function set h(value:Number):void
isFullproperty 
isFull:Boolean

Indicates if the background use full size (use Stage.stageWidth and Stage.stageHeight to resize the background).


Implementation
    public function get isFull():Boolean
    public function set isFull(value:Boolean):void
lineproperty 
line:ILineStyle

Determinates the ILineStyle reference of this display.


Implementation
    public function get line():ILineStyle
    public function set line(value:ILineStyle):void
maxHeightproperty 
maxHeight:Number

This property defined the maximum height of this display.


Implementation
    public function get maxHeight():Number
    public function set maxHeight(value:Number):void
maxWidthproperty 
maxWidth:Number

Defines the maximum width of this display.


Implementation
    public function get maxWidth():Number
    public function set maxWidth(value:Number):void
minHeightproperty 
minHeight:Number

This property defined the mimimun height of this display (This value is >= 0).


Implementation
    public function get minHeight():Number
    public function set minHeight(value:Number):void
minWidthproperty 
minWidth:Number

This property defined the mimimun width of this display (This value is >= 0).


Implementation
    public function get minWidth():Number
    public function set minWidth(value:Number):void
topLeftRadiusproperty 
topLeftRadius:Number

The radius of the upper-left corner, in pixels.


Implementation
    public function get topLeftRadius():Number
    public function set topLeftRadius(value:Number):void
topRightRadiusproperty 
topRightRadius:Number

The radius of the upper-right corner, in pixels.


Implementation
    public function get topRightRadius():Number
    public function set topRightRadius(value:Number):void
useGradientBoxproperty 
public var useGradientBox:Boolean

Indicates if the IFillStyle of this display use gradient box matrix (only if the IFillStyle is a FillGradientStyle).

wproperty 
w:Number

Determinates the virtual height value of this component.


Implementation
    public function get w():Number
    public function set w(value:Number):void
Constructor Detail
Background()Constructor
public function Background(isFull:Boolean = false)

Creates a new Background instance.

Parameters
isFull:Boolean (default = false) — Indicates if the display is full size or not.
Method Detail
addedToStageResize()method
protected function addedToStageResize(e:Event = null):void

Invoked when the display is removed from the stage to enable the autoSize mode.

Parameters

e:Event (default = null)

doLater()method 
public function doLater():void

Launch an event with a delayed interval.

draw()method 
public function draw(... arguments):void

Draw the display.

Parameters

... arguments — The optional arguments to draw the background. With the signature : ( w:Number , h:Number, offsetX:Number, offsetY:Number )

initBackgroundPen()method 
public function initBackgroundPen(graphic:* = null):IPen

Init the pen to draw the background of this display. This method is invoked in the constructor of the class. You can override this method to change the shape of the background.

Parameters

graphic:* (default = null) — The Graphics reference to control with this helper. You can passed-in a Graphics or a Shape or a Sprite/MovieClip reference in argument. If this argument is null the default target it's the main background reference.

Returns
IPen — the IPen reference to draw the background of the display.
notifyResized()method 
public function notifyResized():void

Notify an event when you resize the component.

refresh()method 
public function refresh(init:*):void

Refresh and initialize the display with a generic object and invoke the "update" method.

Parameters

init:*

removedFromStageResize()method 
protected function removedFromStageResize(e:Event = null):void

Invoked when the display is removed from the stage to disable the autoSize mode.

Parameters

e:Event (default = null)

resize()method 
public function resize(e:Event = null):void

Resize and update the background.

Parameters

e:Event (default = null)

setCornerRadius()method 
public function setCornerRadius(n:Number):void

Defines all corner radius of the background (upper-left, upper-right, bottom-left and bottom-right).

Parameters

n:Number

setSize()method 
public function setSize(w:Number, h:Number):void

Sets the virtual width (w) and height (h) values of the component.

Parameters

w:Number
 
h:Number

update()method 
public function update():void

Update the display.

viewChanged()method 
public function viewChanged():void

This method is invoked after the draw() method in the update() method. Overrides this method.

viewEnabled()method 
public function viewEnabled():void

Invoked when the enabled property of the component change. Overrides this method.

viewResize()method 
public function viewResize():void

Invoked when the component is resized. Overrides this method.