style.left = e.clientX + pos.x - pos.h + ???px??™;
el.style.top = e.clientY + pos.y - pos.v + ???px??™;
return false;
};
}
this.draggable = true;
}
Panel.prototype.deactivateDrag = function()
{
this.el.onmousedown = null;
this.el.style.backgroundColor = ???#cccccc???;
(continued)
160
Part I: The Core Language
this.draggable = false;
}
Panel.prototype.hide = function()
{
this.visible = false;
this.el.style.display = ???none??™;
}
Panel.prototype.show = function()
{
this.el.style.display = ???block??™;
this.visible = true;
}
JavaScript is a programming language that does not include a formal definition for classes, but a very
similar structure can be obtained using functions as objects and prototypes.
A wrapper extern class is defined, so that access to the previous code in haXe will be strictly typed and
friendly.
// content of file Panel.hx
extern class Panel
{
public function new(name : String) : Void;
public function activateDrag() : Void;
public function deactivateDrag() : Void;
public function hide() : Void;
public function show() : Void;
public var visible(default, null) : Bool;
public var draggable(default, null) : Bool;
}
The Panel class is used in the example to control the status of a box on the web page.
Pages:
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324