Prev | Current Page 313 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

The page also
includes two buttons, one to pause and to resume the drag functionality of the box, the other to toggle its
visibility. Those behaviors are wired in the main function.
// content of file Main.hx
import js.Dom;
import js.Lib;
class Main
{
static function main()
{
var panel : Panel = new Panel(???mypanel???);
panel.activateDrag();
var btnv : Button = cast Lib.document.getElementById(???buttonVisibilty???);
btnv.onclick = function(event : Event)
{
if(panel.visible)
{
panel.hide();
(continued)
161
Chapter 6: Organizing Your Code
btnv.value = ???show???;
} else {
panel.show();
btnv.value = ???hide???;
}
}
var btnd : Button = cast Lib.document.getElementById(???buttonDrag???);
btnd.onclick = function(event : Event)
{
if(panel.draggable)
{
panel.deactivateDrag();
btnd.value = ???start drag???;
} else {
panel.activateDrag();
btnd.value = ???pause drag???;
}
}
}
}
Compiling the preceding code with the following command produces a main.js script that can be
included in the test page.


Pages:
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325