Skip to content

Commit a777f0d

Browse files
committed
Added more precise abstraction of interfaces
1 parent 872f4b7 commit a777f0d

7 files changed

Lines changed: 264 additions & 7 deletions

File tree

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
/**
22
* Created by jim on 5/19/14.
33
*/
4-
class CommentButton extends Sprite{
4+
class CommentButton extends Sprite implements IComment {
5+
private _mM:MotionManager = new MotionManager(this);
56

7+
constructor(params:Object) {
8+
this.initStyle(params);
9+
}
10+
11+
get motionManager():MotionManager {
12+
return _mM;
13+
}
14+
15+
set motionManager(m):void {
16+
__trace("IComment.motionManager is read-only", "warn");
17+
}
18+
19+
public remove():void {
20+
this.unload();
21+
}
22+
23+
public initStyle(style:Object):void {
24+
25+
}
626
}
Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
/**
22
* Created by jim on 5/19/14.
33
*/
4-
class CommentCanvas extends Sprite{
4+
class CommentCanvas extends Sprite implements IComment {
5+
private _mM:MotionManager = new MotionManager(this);
56

7+
constructor(params:Object) {
8+
this.initStyle(params);
9+
}
10+
11+
get motionManager():MotionManager {
12+
return _mM;
13+
}
14+
15+
set motionManager(m):void {
16+
__trace("IComment.motionManager is read-only", "warn");
17+
}
18+
19+
public remove():void {
20+
this.unload();
21+
}
22+
23+
public initStyle(style:Object):void {
24+
25+
}
626
}
Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
/**
22
* Created by jim on 5/19/14.
33
*/
4-
class CommentField extends TextField{
4+
class CommentField extends TextField implements IComment {
5+
private _mM:MotionManager = new MotionManager(this);
56

7+
constructor(params:Object) {
8+
this.initStyle(params);
9+
}
10+
11+
get motionManager():MotionManager {
12+
return _mM;
13+
}
14+
15+
set motionManager(m):void {
16+
__trace("IComment.motionManager is read-only", "warn");
17+
}
18+
19+
public remove():void {
20+
this.unload();
21+
}
22+
23+
public initStyle(style:Object):void {
24+
25+
}
626
}
Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
/**
2-
* Created by jim on 5/19/14.
2+
* Compliant CommentShape Polyfill For BiliScriptEngine
33
*/
4-
class CommentShape extends Shape{
4+
class CommentShape extends Shape implements IComment {
5+
private _mM:MotionManager = new MotionManager(this);
6+
7+
constructor(params:Object) {
8+
this.initStyle(params);
9+
}
10+
11+
get motionManager():MotionManager {
12+
return _mM;
13+
}
14+
15+
set motionManager(m):void {
16+
__trace("IComment.motionManager is read-only", "warn");
17+
}
18+
19+
public remove():void {
20+
this.unload();
21+
}
22+
23+
public initStyle(style:Object):void {
24+
25+
}
526

627
}
Lines changed: 152 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/**
2-
* Created by jim on 5/19/14.
2+
* Graphics Polyfill for AS3
3+
* Author: Jim Chen
4+
* Part of the CCLScripter
35
*/
46
class Graphics {
57
private id:String;
@@ -8,4 +10,153 @@ class Graphics {
810
id = parent.getId();
911
}
1012

13+
private toRGB(rgb:number):string {
14+
var output:string = parseInt(rgb).toString(16);
15+
while (output.length < 6) {
16+
output = "0" + output;
17+
}
18+
return "#" + output;
19+
}
20+
21+
private callDrawMethod(method:string, params):void {
22+
__pchannel("Runtime:CallMethod", {
23+
"id": id,
24+
"context": "graphics",
25+
"method": method,
26+
"params": params
27+
});
28+
}
29+
30+
/**
31+
* Line to point
32+
* @param x - x coordinate
33+
* @param y - y coordinate
34+
*/
35+
public lineTo(x:number, y:number):void {
36+
callDrawMethod("lineTo", [a, b]);
37+
}
38+
39+
/**
40+
* Move to point
41+
* @param x - x coordinate
42+
* @param y - y coordinate
43+
*/
44+
public moveTo(x:number, y:number):void {
45+
callDrawMethod("moveTo", [x, y]);
46+
}
47+
48+
/**
49+
* Quadratic Beizer Curve
50+
* @param cx - Control point x
51+
* @param cy - Control point y
52+
* @param ax - Anchor x
53+
* @param ay - Anchor y
54+
*/
55+
public curveTo(cx:number, cy:number, ax:number, ay:number):void {
56+
callDrawMethod("curveTo", [cx, cy, ax, ay]);
57+
}
58+
59+
/**
60+
* Cubic Beizer Curve
61+
* @param cax - Control point A x
62+
* @param cay - Control point A y
63+
* @param cbx - Control point B x
64+
* @param cby - Control point B y
65+
* @param ax - Anchor x
66+
* @param ay - Anchor y
67+
*/
68+
public cubicCurveTo(cax:number, cay:number, cbx:number, cby:number, ax:number, ay:number):void {
69+
callDrawMethod("cubicCurveTo", [cax, cay, cbx, cby, ax, ay]);
70+
}
71+
72+
/**
73+
* Set line style
74+
* @param thickness - line thickness
75+
* @param color - line color (default 0)
76+
* @param alpha - alpha (default 1)
77+
* @param hinting - pixel hinting (default false)
78+
* @param scale - scale mode (default "normal")
79+
* @param caps - line cap mode (default "none")
80+
* @param joints - line joint mode (default "round")
81+
* @param miterlim - miter limit (default 3)
82+
*/
83+
public lineStyle(thickness:number, color:number = 0, alpha:number = 1.0, hinting:boolean = false, scale:string = "normal", caps:string = "none", joints:string = "round", miter:number = 3):void {
84+
callDrawMethod("lineStyle", [thickness, color, alpha, caps, joints, miter]);
85+
}
86+
87+
/**
88+
* Draw a rectangle
89+
* @param x - x coordinate
90+
* @param y - y coordinate
91+
* @param w - width
92+
* @param h - height
93+
*/
94+
public drawRect(x:number, y:number, w:number, h:number):void {
95+
callDrawMethod("drawRect", [x, y, w, h]);
96+
}
97+
98+
/**
99+
* Draws a circle
100+
* @param x - center x
101+
* @param y - center y
102+
* @param r - radius
103+
*/
104+
public drawCircle(x:number, y:number, r:number):void {
105+
callDrawMethod("drawCircle", [x, y , r]);
106+
}
107+
108+
/**
109+
* Draws an ellipse
110+
* @param cx - center x
111+
* @param cy - center y
112+
* @param w - width
113+
* @param h - height
114+
*/
115+
public drawEllipse(cx:number, cy:number, w:number, h:number):void {
116+
callDrawMethod("drawEllipse", [cx + w / 2, cy + h / 2, w / 2, h / 2]);
117+
}
118+
119+
/**
120+
* Draws a rounded rectangle
121+
* @param x - x coordinate
122+
* @param y - y coordinate
123+
* @param w - width
124+
* @param h - height
125+
* @param elw - ellipse corner width
126+
* @param elh - ellipse corner height
127+
*/
128+
public drawRoundRect(x:number, y:number, w:number, h:number, elw:number, elh:number):void {
129+
callDrawMethod("drawRoundRect", [x, y, w, h, elw, elh]);
130+
}
131+
132+
/**
133+
* Fill next shape with solid color
134+
* @param color
135+
* @param alpha
136+
*/
137+
public beginFill(color:number, alpha:number = 1.0):void {
138+
callDrawMethod("beginFill", [color, alpha]);
139+
}
140+
141+
public beginGradientFill():void {
142+
__trace("Graphics: Gradients not supported yet.", 'warn');
143+
}
144+
145+
public beginShaderFill():void {
146+
__trace("Graphics: Shaders not supported yet.", 'warn');
147+
}
148+
149+
/**
150+
* Stop and finalize fill
151+
*/
152+
public endFill():void {
153+
callDrawMethod("endFill", []);
154+
}
155+
156+
/**
157+
* Clears everything the current graphics context has drawn
158+
*/
159+
public clear():void {
160+
callDrawMethod("clear", []);
161+
}
11162
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Created by jim on 5/19/14.
3+
*/
4+
interface IComment {
5+
/**
6+
* Motion Manager for Comments
7+
*/
8+
motionManager:MotionManager;
9+
10+
/**
11+
* Removal
12+
*/
13+
remove():void;
14+
15+
/**
16+
* Initialize a style for the class.
17+
* CommentBitmap does not have this
18+
* @param params
19+
*/
20+
initStyle?(params:Object):void;
21+
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
/**
2-
* Created by jim on 5/19/14.
2+
* MotionManager Polyfill for AS3.
3+
* Author: Jim Chen
4+
* Part of the CCLScripter
35
*/
46
class MotionManager{
7+
constructor(o:DisplayObject) {
58

9+
}
610

711
}

0 commit comments

Comments
 (0)