Prev | Current Page 687 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

In Flash
versions older than 9, to create an instance of a class of this type, you must use the
attachMovie() method and cast the returned value to the proper class.
In the following example, the conditional compilation is used to differentiate between Flash 9 and
previous versions; the result is the same on all the supported platforms. In the Picture class a
startSpin() method has been created to demonstrate how easy it is to add new methods to the
imported clip.
Part II: Server Side, JavaScript, and Flash: Oh My!
366
#if flash9
class Main
{
public static function main()
{
var pic = new Picture();
flash.Lib.current.addChild(pic);
pic.startSpin();
}
}
class Picture extends flash.display.MovieClip
{
public function startSpin()
{
var self = this;
addEventListener(???enterFrame???, function(e) { self.rotation++;});
}
}
#else flash
class Main
{
public static function main()
{
var pic = cast(flash.Lib.current.attachMovie(???Picture???, ???pic???, 10), Picture);
pic.startSpin();
}
}
class Picture extends flash.


Pages:
675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699