//
class Main {
Browser.window.onload = function(e:EventListener):Void {
var tmpBox:Box = new Box(); tmpBox.setSize(100, 100); Browser.document.body.appendChild (tmpBox);
}
}
class Box extends js.html.DivElement implements IResizable {
public function new () {
// Actually can't do 'super()' as DivElement doesn't have constructor.. I get it.., but I can't figure it out how to achieve what I want..
//super();
}
/* INTERFACE model.IResizable */
public function setSize(w:Int, h:Int):Void { this.style.width = w+"px";
this.style.height = h+"px";
}
}
@:forward
abstract Box(js.html.DivElement) to js.html.DivElement {
public inline function new(){
this = untyped js.Browser.document.createDivElement();
}
public inline function setSize(w:Int, h:Int):Void {
this.style.width = w+"px";
this.style.height = h+"px";
}
}
var box=new Box();
box.setSize(100,100);
box.innerHTML="Text";
document.body.appendChild(box);
I really appreciate for the sample code. It was big help. Now try to catch up about the keywords abstract and inline that you used.Although, I have experience with AS3, these are pretty new to me. Besides, how do you call the thing you used.. like the '@:forward' ?I want to find further information about it. Again, many thanks. :)
On Tuesday, July 22, 2014 5:32:09 AM UTC+8, Porfírio Ribeiro wrote:Or you may also use an abstract to wrap it arround like this
@:forward
abstract Box(js.html.DivElement) to js.html.DivElement {
public inline function new(){
this = untyped js.Browser.document.createDivElement();
}
public inline function setSize(w:Int, h:Int):Void {
this.style.width = w+"px";
this.style.height = h+"px";
}
}
Then use it like:
var box=new Box();
box.setSize(100,100);
box.innerHTML="Text";
document.body.appendChild(box);
--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.