AS3 wrappers for createjs toolkit

30 views
Skip to first unread message

Yogesh Maheshwari

unread,
Nov 15, 2015, 8:44:42 PM11/15/15
to Jangaroo Users
Hey Frank,

I would like to create AS3 wrapper for CreateJS toolkit, but I am not very sure as to how to use the [Native] annotation you have provide in jangaroo.
I have read the following post but the link for soundmanger2 seems to be broken.
https://groups.google.com/forum/?fromgroups=#!topic/jangaroo-users/SqC0PSIiPnk

I would be greatful if you could help.

Sincerely,

Yogesh Maheshwari

Yogesh Maheshwari

unread,
Nov 15, 2015, 8:59:20 PM11/15/15
to Jangaroo Users
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.as

package 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


Reply all
Reply to author
Forward
0 new messages