Prev | Current Page 648 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

PI/3;
public static var D45 = Math.PI/4;
public static var D30 = Math.PI/6;
public static var D15 = Math.PI/12;
}
There are just three lines in the whole code that make use of the drawing API and they are located in the
method Tree.generate() ; nevertheless the result can be quite complex.
The class in the preceding example can be used to generate one tree as follows:
import Tree;
import flash.Lib;
class Main
{
// change these values to match the movie size
private static var w = 640;
private static var h = 480;
public static function main()
{
#if flash9
var tree = new Tree(Lib.current.graphics);
#else flash
var tree = new Tree(Lib.current);
#end
tree.generate(w/2, h);
}
}
Part II: Server Side, JavaScript, and Flash: Oh My!
340
The same class can be used to generate more complex scenes as in the following example.
import Tree;
import flash.Lib;
#if flash9
import flash.display.GradientType;
import flash.display.MovieClip;
import flash.events.MouseEvent;
#end
class Main
{
// change these values to match the movie size
private static var w = 640;
private static var h = 480;
public static function main()
Figure 12-3
In Figure 12 - 3 , the image of a tree is generated with the example code.


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