不工作我使用的是最新的kineticjs。(v.3.10) 这里的问题是Layer.remove(Image);在Kinetic.js
我使用的是单一的功能将图像发送到画布这些都对点击画布外。 我正在使图像拖动和所有.. 我也添加了删除图像功能双击。 当我双击任何图像.. 最后添加的图像被删除,之后,如果我尝试点击一些其他图像.. 我得到这个错误:TypeError:this.children [child.index]是undefined
这里是一个小代码:
使用此功能,使用AJAX
function loadajax(imgpath,imgid){
sources = {
yoda1 : imgpath,
};
loadImages(sources,initStage1);
};
来源函数来从另一个文件的路径:----
function loadImages(sources, callback){
var images = {};
var loadedImages = 0;
var numImages = 0;
for (var src in sources) {
numImages++;
}
for (var src in sources) {
images[src] = new Image();
images[src].onload = function(){
if (++loadedImages >= numImages) {
callback(images);
}
};
images[src].src = sources[src];
}
}
下面是我使用删除/拖放/等功能..
function initStage1(images){
yodaGroup1 = new Kinetic.Group({
x: 100,
y: 110,
draggable: true,
});
layery = new Kinetic.Layer();
layery.add(yodaGroup1);
stage.add(layery);
var yoda1 = new Kinetic.Image({
image: images.yoda1,
x: 0,
y: 0,
width: 100,
height: 120,
name:"image",
detectionType:"Pixel"
});
yodaGroup1.add(yoda1);
yodaGroup1.on("dragstart", function() {
yodaGroup1.moveToTop();
layery.draw();
});
yodaGroup1.on("dblclick dbltap", function() {
layery.remove(yodaGroup1);
layery.draw();
});
yodaGroup1.on("dragend", function() {
layery.draw();
yoda1.saveImageData();
});
addAnchor(yodaGroup1,0, 0, "topLeft");
addAnchor(yodaGroup1, 100, 0, "topRight");
addAnchor(yodaGroup1, 100, 120, "bottomRight");
addAnchor(yodaGroup1, 0, 120, "bottomLeft");
stage.draw();
yoda1.saveImageData();
}
现按这个功能 我应该能够将图像添加到画布上(这是工作精) 应能对另一移动一个图像,当我将它拖到(.ie.moveToTop功能)_Not工作 应该能去除双击()的图像仅最新添加的图像工作
请帮助
Tha NKS