Fix binding issues
This commit is contained in:
1 parent
f161640876
commit
4b5e7a57a5
2 files changed
+14
-16
No files matched your search
@@ -7,7 +7,7 @@ var log = require('../util/log');
|
||||
* @property {string} md5 - the MD5 and extension of the sound to be loaded.
|
||||
* @property {Buffer} data - sound data will be written here once loaded.
|
||||
* @param {!Runtime} runtime - Scratch runtime, used to access the storage module.
|
||||
* @returns {!Promise} - a promise which will resolves to the sound when ready.
|
||||
* @returns {!Promise} - a promise which will resolve to the sound when ready.
|
||||
*/
|
||||
var loadSound = function (sound, runtime) {
|
||||
if (!runtime.storage) {
|
||||
|
||||
+13
-15
@@ -153,24 +153,23 @@ VirtualMachine.prototype.postIOData = function (device, data) {
|
||||
* @return {!Promise} Promise that resolves after targets are installed.
|
||||
*/
|
||||
VirtualMachine.prototype.loadProject = function (json) {
|
||||
var that = this;
|
||||
// @todo: Handle other formats, e.g., Scratch 1.4, Scratch 3.0.
|
||||
return sb2import(json, this.runtime).then(function (targets) {
|
||||
that.clear();
|
||||
this.clear();
|
||||
for (var n = 0; n < targets.length; n++) {
|
||||
if (targets[n] !== null) {
|
||||
that.runtime.targets.push(targets[n]);
|
||||
this.runtime.targets.push(targets[n]);
|
||||
targets[n].updateAllDrawableProperties();
|
||||
}
|
||||
}
|
||||
// Select the first target for editing, e.g., the first sprite.
|
||||
that.editingTarget = that.runtime.targets[1];
|
||||
this.editingTarget = this.runtime.targets[1];
|
||||
|
||||
// Update the VM user's knowledge of targets and blocks on the workspace.
|
||||
that.emitTargetsUpdate();
|
||||
that.emitWorkspaceUpdate();
|
||||
that.runtime.setEditingTarget(that.editingTarget);
|
||||
});
|
||||
this.emitTargetsUpdate();
|
||||
this.emitWorkspaceUpdate();
|
||||
this.runtime.setEditingTarget(this.editingTarget);
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -195,15 +194,14 @@ VirtualMachine.prototype.downloadProjectId = function (id) {
|
||||
*/
|
||||
VirtualMachine.prototype.addSprite2 = function (json) {
|
||||
// Select new sprite.
|
||||
var that = this;
|
||||
sb2import(json, this.runtime, true).then(function (targets) {
|
||||
that.runtime.targets.push(targets[0]);
|
||||
that.editingTarget = targets[0];
|
||||
this.runtime.targets.push(targets[0]);
|
||||
this.editingTarget = targets[0];
|
||||
// Update the VM user's knowledge of targets and blocks on the workspace.
|
||||
that.emitTargetsUpdate();
|
||||
that.emitWorkspaceUpdate();
|
||||
that.runtime.setEditingTarget(that.editingTarget);
|
||||
});
|
||||
this.emitTargetsUpdate();
|
||||
this.emitWorkspaceUpdate();
|
||||
this.runtime.setEditingTarget(this.editingTarget);
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user