package{ import flash.display.Sprite; public class Main extends Sprite{ public function Main(){ try { drawRectangle(this, 100, 200); drawRectangle(this, 300, 400); } catch(errObject:Error) { this.graphics.clear( ); trace("An error occurred: " + errObject.message); } } private function drawRectangle(sprite:Sprite, nWidth:Number, nHeight:Number):void { if(isNaN(nWidth) || isNaN(nHeight)) { throw new Error("Invalid dimensions specified."); } sprite.graphics.lineStyle(1, 0, 1); sprite.graphics.lineTo(nWidth, 0); sprite.graphics.lineTo(nWidth, nHeight); sprite.graphics.lineTo(0, nHeight); sprite.graphics.lineTo(0, 0); } }}
Name (required)
email (will not be published) (required)
Website