Graphics Reference
In-Depth Information
Table 12.1 The Private Variables of the
BorderButton Class
Variable
Purpose
_bbParent (DisplayObjectContainer)
The parent object of the BorderButton
_halfThick (Number)
Half the thickness of the border line
_w (Number)
Width to draw the BorderButton
_h (Number)
Height to draw the BorderButton
_targetWindow (String)
Window where targeted URL will open
_request (URLRequest)
Used to launch the target URL
Table 12.2 Parameters for the Draw Method
Parameter
Purpose
parent (DisplayObjectContainer)
The parent where the BorderButton will be added as a child
outline (Boolean)
Determines if the BorderButton will have the border or not; default
is false
lineColor (uint)
The color of the border; default is black
lineThickness (int)
The thickness of the border; default is 1 pixel thick
'
ll get to the real functionality of the BorderButton
class with the draw method. The draw method does exactly what
you probably guessed it does: it draws the BorderButton by using
the parameters (Table 12.2) passed in by you, the developer. Note
the use of the _halfThick variable in this method. Because of the
way that Flash draws out the lines, I
Now, we
ve learned that I have to pull
the width and height of my button in by half the thickness of the
line. If this is not done and your button goes right to the edge of
the stage, you
'
ll notice half of the border getting cut off from the
right and bottom.
'
public function draw(parent:DisplayObjectContainer,
outline:Boolean = false, lineColor:uint = 0x000000,
lineThickness:int = 1):void {
_bbParent = parent;
_bbParent.addChild(this);
_halfThick = lineThickness / 2;
_w = stage.stageWidth
_halfThick;
-
_h = stage.stageHeight
_halfThick;
-
Search WWH ::




Custom Search