0

I'm importing a JSON layer to the stage.

var loadedobject = Kinetic.Node.create(data);
        maplayer.add(loadedobject);

Code to change the content what I'm importing seems to do like fine: (BTW: .maplayer2 is the layer I have imported)

maplayer.get('.maplayer2')[0].setScale(browserwidthdifference);
            maplayer.get('.maplayer2')[0].setY(browserheight/2);
            maplayer.setDraggable(true);

However if do the code below it doesn't work:

maplayer.on('click', function() {
                console.log('help');    
            });


maplayer.get('.maplayer2')[0].on('click', function() {
                console.log('help');    
            });

I have let the background black of the imported layer so I can see the detection. However if I do:

backgroundlayer.on('click', function() {
                console.log('help');    
            });

I get the click responses even if I click on the imported layer which is clearly on top of the other layer. maplayer.moveToTop() doens't work either. All alternations work but the click events won't work with the imported object.

If I create another object in maplayer it will response to it when I click on it, but the imported layer in the layer will still be not detected.

enter image description here

4

1 回答 1

0

If you save all objects within a group object it will work fine! So when you save things do not do it within a Layer but in a Group object.

于 2013-05-01T08:17:18.610 回答