Thought I’d share this little shortcut that I hadn’t really come across before, which definitely helps to keep your code that little cleaner when working with MovieClip.graphics in Flash.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | this.grapics.lineStyle(1, 0x00000); this.graphics.moveTo(10, 10); this.graphics.lineTo(10, 20); this.graphics.lineTo(20, 20); this.graphics.lineTo(20, 10); this.graphics.lineTo(10, 10); this.graphics.beginFill(0xFF0000); this.graphics.drawCircle(40, 40, 20); this.graphics.endFill(); this.graphics.beginFill(0x00FF00); this.graphics.drawRoundRect(40, 0, 40, 20, 2, 2); this.graphics.endFill(); |
Can also be written:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | with (this.graphics) { lineStyle(1, 0x00000); moveTo(10, 10); lineTo(10, 20); lineTo(20, 20); lineTo(20, 10); lineTo(10, 10); beginFill(0xFF0000); drawCircle(40, 40, 20); endFill(); beginFill(0x00FF00); drawRoundRect(40, 0, 40, 20, 2, 2); endFill(); } |
Pretty simple, and surprised I hadn’t seen (or thought of) it before.


