使用Node.create从json字符串加载会引发异常

时间:2012-12-14 16:33:06

标签: kineticjs

在此页面上 http://entropy.tmok.com/~gauze/canvas/load.html

我收到错误:TypeError:this._createNode不是函数

与此功能有关:

Kinetic.Node.create = function(json, container) {
    return this._createNode(JSON.parse(json), container);
}; 

我正在使用的json字符串是从stage.toJSON()调用中复制粘贴的,当我在上面的函数中断时,根据firebug,this的值是“Window load.html”。

任何帮助?

1 个答案:

答案 0 :(得分:1)

您只需在创建节点时删除new 所以......

var stage = new Kinetic.Node.create(json, 'container');​

......变成......

var stage = Kinetic.Node.create(json, 'container');​

....然后它应该工作正常。