Prev | Current Page 297 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

lineTo(x+w, y+h);
g.lineTo(x, y+h);
g.lineTo(x, y);
}
public function drawPoly(coords: Array < Array < Int > > )
{
g.lineStyle(2, 0x000000);
g.moveTo(coords[0][0], coords[0][1]);
for(i in 1...coords.length) {
g.lineTo(coords[i][0], coords[i][1]);
}
}
}
152
Part I: The Core Language
Importing a library in the ways described later is insane when the source code is available and it can be
used simply with the class - path switch. In the following examples you are simulating that the Drawer
class is part of a foreign library that you need to use, but it is not available in source format or the source
format is not compatible with haXe and you cannot translate it rapidly.
The class is targeting generically the Flash platform. Drawing functionalities, as almost everything else,
have changed a lot between version 9 and the previous ones. In the previous code, the differences are
removed using the conditional compilation. In this case, Flash 9 uses the Graphics class to draw, while
versions 6 to 8 draw directly on a MovieClip instance.


Pages:
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309