Prev | Current Page 653 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

lineTo(50, 120);
mc.lineTo(50, 50);
mc.endFill();
}
}
Figure 12-4
(continued)
Part II: Server Side, JavaScript, and Flash: Oh My!
344
class MaskedClip extends MovieClip
{
private var mask : MovieClip;
public function setMaskSize(w : Float, h : Float)
{
if(mask == null) {
mask = createEmptyMovieClip(???mask???, 0);
setMask(mask);
}
mask.clear();
mask.beginFill(0x000000);
mask.moveTo(0, 0);
mask.lineTo(w, 0);
mask.lineTo(w, h);
mask.lineTo(0, h);
mask.lineTo(0, 0);
mask.endFill();
}
}
The example produces a diamond shape. Note that as the identifier for the symbol has been used, the
same name of the class and how the movie clip was created with attachMovie() must be properly
cast to be used as an instance of MaskedClip . Finally, even if it is possible to define a constructor that
performs some initialization actions, it is not possible to define and pass arguments for it.
The same extending technique allows you to associate custom code to a symbol created with a visual
editor such as the Flash IDE and embedded in the output movie using the - swf - lib switch.


Pages:
641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665