Graphics Reference
In-Depth Information
public function erase():void{
if(_bbParent != null){
deactivate();
_bbParent.removeChild(this);
}
}
public function deactivate():void{
if(hasEventListener(MouseEvent.CLICK)){
buttonMode = false;
removeEventListener(MouseEvent.CLICK,clickOut);
}
}
private function clickOut(e:MouseEvent):void {
try {
navigateToURL(_request, _targetWindow);
}catch (e:Error){
trace(
"
An error occurred trying to navigate
to the target url.
"
);
}
}
}
}
BorderButton Breakdown
On the very first lines of the BorderButton class, you
'
ll see the
package declaration and the imports used within.
package com.flashadbook.display {
import flash.display.DisplayObjectContainer;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.net.navigateToURL;
Next is the class declaration where you
ll notice the use of the
final class attribute and the fact that the BorderButton extends Sprite.
A Sprite is a very basic display object that gives us access to properties
like graphics, so we can draw out the border. The access to the gra-
phics property also allows us to use drawRect a bit further in. Directly
inside the class constructor, we
'
'
ll set up the variables in Table 12.1.
public final class BorderButton extends Sprite{
The next item in the lineup is the class constructor that, in this
case, is really just an empty function that reestablishes the call to
the parent class (Sprite) with super .
public function BorderButton(){
super();
}
Search WWH ::




Custom Search