Hey Frank,
Consider the following code myrect.js,
myrect.as, Main.as
myrect.js
this.Rect = this.Rect||{};
(function(){
function myrect(x1,y1,x2,y2)
{
this.x1 = x1;
this.x2 = x2;
this.y1 = y1;
this.y2 = y2;
};
var p = myrect.prototype;
p.to_string = function(){
return "Rect["+this.x1+","+this.y1+","+this.x2+","+this.y2+"]";
};
p.draw = function(){
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.rect(this.x1,this.y1,this.x2,this.y2);
ctx.stroke();
};
this.Rect.myrect = myrect;
}());
myrect.aspackage Rect{
[Native]
public class myrect{
public function myrect(x1:Number,y1:Number,x2:Number,y2:Number){
}
public native function draw():void;
public native function to_string():String;
}
}
Main.as
package {
import flash.display.Sprite;
import flash.text.TextField;
import Rect.myrect;
[SWF( backgroundColor='0xFFFFFF', frameRate='30', width='640', height='480')]
public class Main extends Sprite {
public function Main() {
var helloWorld:TextField = new TextField();
var rec:myrect = new myrect(10,20,100,200);
helloWorld.text = rec.to_string();
addChild(helloWorld);
}
}
}
With respect to these files I would like to know the following:
1. Syntactic error in code, in terms of using native.
2. Structure of the project, i.e. which file should be where in src/main/joo
3. Changes in .pom or .as3proj file if any.
Sincerely,
Yogesh