Skip to content

Commit f7d87d1

Browse files
committed
Player and Runtime are now mostly drop-in compatible.
1 parent c975b32 commit f7d87d1

14 files changed

Lines changed: 1431 additions & 820 deletions

File tree

.idea/workspace.xml

Lines changed: 149 additions & 225 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/scripting/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ clean:
66

77
compile:
88
tsc --target ES5 src/api/Display/Display.ts --out build/api/Display.js
9+
tsc --target ES5 src/api/Runtime/Runtime.ts --out build/api/Runtime.js
10+
tsc --target ES5 src/api/Player/Player.ts --out build/api/Player.js
911
cp src/*.js build/
1012
cp src/api/*.js build/api/
11-
cp src/api/Player/Player.js build/api/
1213
cp src/api/Tween/Tween.js build/api/
13-
cp src/api/Runtime/Runtime.js build/api/

src/scripting/build/Host.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ var CCLScripting = function(workerUrl){
1212
console.warn(m);
1313
};
1414
};
15-
this.toRGB = function(number){
16-
var string = parseInt(number).toString(16);
17-
while(string.length < 6){
18-
string = "0" + string;
19-
}
20-
return "#" + string;
21-
};
2215
this.getWorker = function(){
2316
return new Worker(this.workerUrl);
2417
};
@@ -427,7 +420,13 @@ var CCLScripting = function(workerUrl){
427420
fill:"none",
428421
alpha:1
429422
};
430-
423+
var toRGB = function(number){
424+
var string = parseInt(number).toString(16);
425+
while(string.length < 6){
426+
string = "0" + string;
427+
}
428+
return "#" + string;
429+
};
431430
var applyStroke = function(p, ref){
432431
__(p, {
433432
"stroke": ref.line.color,
@@ -508,7 +507,7 @@ var CCLScripting = function(workerUrl){
508507
if(params.length < 3)
509508
return;
510509
this.line.width = params[0];
511-
this.line.color = CCLScripting.toRGB(params[1]);
510+
this.line.color = toRGB(params[1]);
512511
this.line.alpha = params[2];
513512
if(params[3]){
514513
this.line.caps = params[3];
@@ -526,7 +525,7 @@ var CCLScripting = function(workerUrl){
526525
this.beginFill = function(params){
527526
if(params.length === 0)
528527
return;
529-
this.fill.fill = CCLScripting.toRGB(params[0]);
528+
this.fill.fill = toRGB(params[0]);
530529
if(params.length > 1){
531530
this.fill.alpha = params[1];
532531
}

src/scripting/build/api/Display.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,12 +446,16 @@ var Display;
446446
}
447447
};
448448

449+
/**
450+
* Removes the object from a parent if exists.
451+
*/
449452
DisplayObject.prototype.remove = function () {
450453
// Remove itself
451454
if (this._parent !== null) {
452455
this._parent.removeChild(this);
456+
} else {
457+
this.root.removeChild(this);
453458
}
454-
this.unload();
455459
};
456460

457461
/** Common Functions **/
@@ -471,6 +475,7 @@ var Display;
471475

472476
DisplayObject.prototype.unload = function () {
473477
this._visible = false;
478+
this.remove();
474479
__pchannel("Runtime:CallMethod", {
475480
"id": this._id,
476481
"method": "unload",
@@ -1048,6 +1053,11 @@ var Display;
10481053
__pchannel("Display:SetFrameRate", value);
10491054
}
10501055
});
1056+
1057+
function toString() {
1058+
return "[display Display]";
1059+
}
1060+
Display.toString = toString;
10511061
})(Display || (Display = {}));
10521062

10531063
var $ = Display;

0 commit comments

Comments
 (0)