Game Development Reference
In-Depth Information
_clickHighlight.graphics.beginFill(0xFFFFFF, .2);
_clickHighlight.graphics.drawRect(1, 1, _image.width-2,
_image.height-2);
_clickHighlight.graphics.endFill();
addChild(_clickHighlight);
_clickHighlight.visible = false;
}
These two methods create the aforementioned Shape instances
that will constitute the piece
s alternate states. Both of them are
arbitrarily defined and could be styled any number of ways or even
make reference to clips in the FLA library.
'
public function get index():int { return _index; }
public function set index(value:int):void {
_index = value;
}
public function get currentIndex():int { return _currentIndex; }
public function set currentIndex(value:int):void {
_currentIndex = value;
}
public function get image():BitmapData { return _image.
bitmapData; }
public function set image(value:BitmapData):void {
if (!_image) {
_image = new Bitmap(value);
addChild(_image);
createRolloverHighlight();
createClickHighlight();
}
else _image.bitmapData = value;
}
These accessor methods are implementations from the interface.
The only one that requires a little extra explanation is the set func-
tion for the image property. If the image already exists, it is
assigned directly to the Bitmap instance. If not, it creates the Bit-
map and the highlighted states.
protected function onClick(e:MouseEvent):void {
select();
}
protected function onRollOver(e:MouseEvent):void {
Search Nedrilad ::




Custom Search