topical media & game development
#graphic-flex-image-effects-01-Flex-DrawingSolidFills.ax
#graphic-flex-image-effects-01-Flex-DrawingSolidFills.ax
[swf]
[flash]
flex
package {
import flash.display.Sprite;
import flash.events.MouseEvent;
[SWF(width=550, height=400, backgroundColor=0xFFFFFF)]
Redraws the background of the stage every mouse click.
public class @ax-graphic-flex-image-effects-01-Flex-DrawingSolidFills extends Sprite {
Constructor. Sets up listener for mouse click and draws initial background.
public function @ax-graphic-flex-image-effects-01-Flex-DrawingSolidFills() {
stage.addEventListener(MouseEvent.CLICK, onStageClick);
drawBackground();
}
Draws a solid rectangle of random color over the stage.
private function drawBackground():void {
graphics.clear();
graphics.beginFill(Math.random()*0xFFFFFF);
graphics.lineTo(stage.stageWidth, 0);
graphics.lineTo(stage.stageWidth, stage.stageHeight);
graphics.lineTo(0, stage.stageHeight);
graphics.lineTo(0, 0);
graphics.endFill();
}
Handler for when the stage is clicked. Forces redraw().
private function onStageClick(event:MouseEvent):void {
drawBackground();
}
}
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.