Prev | Current Page 646 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


Some parameter may be adjusted and tuned to obtain very different results. Because the code to target
Part II: Server Side, JavaScript, and Flash: Oh My!
338
the various versions does not vary a lot, a unique code is written addressing the differences with the
conditional compilation. The following code goes in a file named Tree.hx :
#if flash9
import flash.display.Graphics;
#else flash
import flash.MovieClip;
#end
class Tree
{
#if flash9
public var container : Graphics;
#else flash
public var container : MovieClip;
#end
public var branches : Int;
public var length : Float;
public var angle : Float;
public var width : Float;
public var color : Int;
public function new(c)
{
container = c;
branches = 4;
length = 80;
angle = Angle.D90;
width = 10;
color = 0x000000;
}
public function generate(x:Float,y:Float,?len:Float,?ang:Float,?width:Float)
{
// when parameters are missing, generate the first branch using
// the class parameters
if(len == null)
len = this.length;
if(ang == null)
ang = Angle.


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