Prev | Current Page 645 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


The biggest difference between the implementation of the drawing API in the last Flash version and the
previous ones is that in the first case all the drawing methods have been collected in a Graphics class
while in the latter case the methods are directly in the MovieClip class. The graphics property of the
class Sprite is of type Graphics ; Sprite is an ancestor to MovieClip . The Flash 9 implementation also
has a richer set of drawing tools. The basic drawing has remained unchanged: First a starting point is
determined using the method moveTo() , the default position is 0,0 , then a style for the line is set with
lineStyle() if not already defined, and then lines and curves are traced using respectively the
lineTo() and curveTo() methods. To draw filled shapes, the defined path must be enclosed between
the calls to the beginFill() and to the endFill() methods.
The following example demonstrates how very few lines of code leveraging the drawing API can be
used to create beautiful drawings. The intent is to create a Tree class that generates random tree shapes.


Pages:
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657