Prev | Current Page 302 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

drawRect(20, 20, 80, 100);
drawer.drawPoly([ [120, 10], [170, 100], [ 70, 100], [120, 10]]);
}
}
The external movie clip is loaded inside the main one using the loadMovie of the MovieClip class. To
be sure that the imported class is available, the movie clip just loops in the onEnterFrame event waiting
for the external movie to be completely loaded. Once loaded, the repeating call to onEnterFrame is
removed, an instance of Drawer is created, and the function draw is invoked. Note that there is no
information about the class Drawer at compilation time and, thus, the object must necessarily be passed
as Dynamic in the draw function and the instance must be created using reflection. There are alternatives
to the onEnterFrame event to ensure that the movie has been loaded (this example will end in an
infinite loop if the f6.swf is not available for some reason and will not report any error about it), but
this method is short and easy to read.
(continued)
155
Chapter 6: Organizing Your Code
// content of file Main.


Pages:
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314