Graphics Reference
In-Depth Information
BorderButton Code
package com.flashadbook.classes {
import flash.display.DisplayObjectContainer;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.net.navigateToURL;
public class BorderButton extends Sprite{
private var _bbParent:DisplayObjectContainer; //the
parent of the BorderButton
private var _halfThick:Number; //half the thickness
of the border line
private var _w:Number; //the width to draw the
BorderButton
private var _h:Number; //the height to draw the
BorderButton
private var _targetWindow:String; //the window in
which the targetURL will open
private var _request:URLRequest = new URLRequest();
//the URLRequest used to get to the target url
public function BorderButton(){
super();
}
public function draw(parent:DisplayObjectContainer,
outline:Boolean = false, lineColor:uint = 0x000000,
lineThickness:int = 1):void {
_bbParent = parent;
_bbParent.addChild(this);
_halfThick = lineThickness / 2;
_w = _bbParent.stage.stageWidth - _halfThick;
_h = _bbParent.stage.stageHeight - _halfThick;
graphics.lineStyle(lineThickness, lineColor);
graphics.beginFill(0, 0);
graphics.drawRect(0, 0, _w, _h);
}
public function activate(targetUrl:String,
targetWindow:String = " _blank " ):void {
buttonMode = true;
_request.url = targetUrl;
_targetWindow = targetWindow;
if(!hasEventListener(MouseEvent.CLICK)){
addEventListener(MouseEvent.CLICK,
clickOut, false, 0, true);
}
}
Search WWH ::




Custom Search