0

I am creating a 10x10 grid of shapes and attaching a click event to each shape

var g = new Graphics();

    for (var x=0; x<10; ++x) {

        for (var y=0; y<10; ++y) {

            var s = new Shape();
            //s.cache(0, 0, self.segmentWidth, self.segmentWidth);

            s.graphics.beginFill('rgba(0,0,255,.4)');
            s.graphics.drawRect(0, 0, self.segmentWidth, self.segmentWidth);

            s.x = x * self.segmentWidth;
            s.y = y * self.segmentWidth;

            var id = s.x + '_' + s.y;
            self.cells[id] = s;

            self.stage.addChild(s);

            s.addEventListener('click', self.cellClick);
        }

    }

But when I call self.cellClick the targets coords are always 0

this.cellClick = function(e) {
    var s = e.target;
    console.log(s); // x : 0, y : 0
    self.cells[s.x + '_' + s.y].alpha = 0.5;

    self.update = true;
}

does anyone know why this would be happening?

Thanks

Cjmarkham
  • 9,484
  • 5
  • 48
  • 81
  • Hm, did you check what the actual `target` is, is it the Shape or maybe the stage? - I'm referring to the output of `console.log(s);` that can't just be x+y, it must print out all properties of the target. – olsn Aug 15 '13 at 11:48
  • Hi, the issue has been resolved. I tested in firefox and it worked fine. The issue was down to having chromes console open at the time. For some reason some mouse events(mouseover,mouseout etc) dont work, and it also messed up the coords for some reason. – Cjmarkham Aug 16 '13 at 11:27

0 Answers0