| Package | vegas.display |
| Class | public class Background |
| Inheritance | Background CoreSprite flash.display.Sprite |
| Implements | Directionable, Drawable |
| Subclasses | CoreComponent, Cover, Protector |
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." ) ;
| Property | Defined 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 | ||
![]() | logger : 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 | ||
| Method | Defined 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 | ||
![]() | isLocked():Boolean
Returns true if the object is locked. | CoreSprite | |
![]() | lock():void
Locks the object. | CoreSprite | |
notifyResized():void
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 | ||
![]() | 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 | ||
![]() | unlock():void
Unlocks the display. | CoreSprite | |
update():void
Update the display. | Background | ||
viewChanged():void
This method is invoked after the draw() method in the update() method. | Background | ||
viewEnabled():void
Invoked when the enabled property of the component change. | Background | ||
viewResize():void
Invoked when the component is resized. | Background | ||
| Method | Defined By | ||
|---|---|---|---|
![]() | 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 | ||
![]() | 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 | ||
| align | property |
align:uintThe alignement of the background.
public function get align():uint public function set align(value:uint):voidSee also
| autoSize | property |
autoSize:BooleanIndicates if the background is resizing when the stage resize event is invoked.
public function get autoSize():Boolean public function set autoSize(value:Boolean):void| bottomLeftRadius | property |
bottomLeftRadius:NumberThe radius of the bottom-left corner, in pixels.
public function get bottomLeftRadius():Number public function set bottomLeftRadius(value:Number):void| bottomRightRadius | property |
bottomRightRadius:NumberThe radius of the bottom-right corner, in pixels.
public function get bottomRightRadius():Number public function set bottomRightRadius(value:Number):void| direction | property |
direction:StringIndicates the direction value of the background when the display is in this "full" mode (default value is null).
public function get direction():String public function set direction(value:String):voidSee also
| fill | property |
fill:IFillStyleDeterminates the IFillStyle reference of this display.
public function get fill():IFillStyle public function set fill(value:IFillStyle):void| gradientMatrix | property |
public var gradientMatrix:MatrixThe matrix value to draw the gradient fill. This property override the gradientRotation and gradientTranslation properties.
| gradientRotation | property |
public var gradientRotation:Number = 0The rotation value to draw the gradient fill.
| gradientTranslation | property |
public var gradientTranslation:PointThe translation vector to draw the gradient fill.
| h | property |
h:NumberDeterminates the virtual height value of this component.
public function get h():Number public function set h(value:Number):void| isFull | property |
isFull:BooleanIndicates if the background use full size (use Stage.stageWidth and Stage.stageHeight to resize the background).
public function get isFull():Boolean public function set isFull(value:Boolean):void| line | property |
line:ILineStyle
Determinates the ILineStyle reference of this display.
public function get line():ILineStyle public function set line(value:ILineStyle):void| maxHeight | property |
maxHeight:NumberThis property defined the maximum height of this display.
public function get maxHeight():Number public function set maxHeight(value:Number):void| maxWidth | property |
maxWidth:NumberDefines the maximum width of this display.
public function get maxWidth():Number public function set maxWidth(value:Number):void| minHeight | property |
minHeight:NumberThis property defined the mimimun height of this display (This value is >= 0).
public function get minHeight():Number public function set minHeight(value:Number):void| minWidth | property |
minWidth:NumberThis property defined the mimimun width of this display (This value is >= 0).
public function get minWidth():Number public function set minWidth(value:Number):void| topLeftRadius | property |
topLeftRadius:NumberThe radius of the upper-left corner, in pixels.
public function get topLeftRadius():Number public function set topLeftRadius(value:Number):void| topRightRadius | property |
topRightRadius:NumberThe radius of the upper-right corner, in pixels.
public function get topRightRadius():Number public function set topRightRadius(value:Number):void| useGradientBox | property |
public var useGradientBox:BooleanIndicates if the IFillStyle of this display use gradient box matrix (only if the IFillStyle is a FillGradientStyle).
| w | property |
w:NumberDeterminates the virtual height value of this component.
public function get w():Number public function set w(value:Number):void| Background | () | Constructor |
public function Background(isFull:Boolean = false)Creates a new Background instance.
ParametersisFull:Boolean (default = false) — Indicates if the display is full size or not.
|
| addedToStageResize | () | method |
protected function addedToStageResize(e:Event = null):voidInvoked when the display is removed from the stage to enable the autoSize mode.
Parameters
e:Event (default = null) |
| doLater | () | method |
public function doLater():voidLaunch an event with a delayed interval.
| draw | () | method |
public function draw(... arguments):voidDraw 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):IPenInit 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.
|
IPen — the IPen reference to draw the background of the display.
|
| notifyResized | () | method |
public function notifyResized():voidNotify an event when you resize the component.
| refresh | () | method |
public function refresh(init:*):voidRefresh and initialize the display with a generic object and invoke the "update" method.
Parameters
init:* |
| removedFromStageResize | () | method |
protected function removedFromStageResize(e:Event = null):voidInvoked 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):voidResize and update the background.
Parameters
e:Event (default = null) |
| setCornerRadius | () | method |
public function setCornerRadius(n:Number):voidDefines 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):voidSets the virtual width (w) and height (h) values of the component.
Parameters
w:Number | |
h:Number |
| update | () | method |
public function update():voidUpdate the display.
| viewChanged | () | method |
public function viewChanged():voidThis method is invoked after the draw() method in the update() method. Overrides this method.
| viewEnabled | () | method |
public function viewEnabled():voidInvoked when the enabled property of the component change. Overrides this method.
| viewResize | () | method |
public function viewResize():voidInvoked when the component is resized. Overrides this method.