0

I have a problem with kinetics object:

I have some kinetics objects...

var trianguloG1 = new Kinetic.Polygon({ 
points: [x, y, catetosTiangulosGrandes+x, y, x, catetosTiangulosGrandes+y, x, y],
fill: '#7e4f00',
draggable: true
});
layer.add(trianguloG1);

Next objects are similar...

Now, I want apply shadow effects in objects (using an array) on click event, but I have an error

var figuras = [ "trianguloG1",
                 "trianguloMediano",
                 "cuadrado",
                 "trianguloPeque1",
                 "trianguloG2",
                 "trianguloPeque2",
                 "paralelogramo1",
                 "paralelogramoEspejo" ];
for(i=0; i<figuras.length; i++) {
    var figurita=figuras[i];
console.log(figurita);
figurita.on('click', function() { //TypeError: figurita.on is not a function
    figurita.setShadowBlur(8);

            //....... more code

Is possible to do this using an array? What is the reason for this error?

12
  • Get rid of the quotes, e.g. figuras=[trianguloG1, ... Commented Jul 17, 2013 at 8:36
  • Ok. Now it's ok but don't work: var figuras=[trianguloG1,trianguloMediano,cuadrado,trianguloPeque1,trianguloG2,trianguloPeque2,paralelogramo1,paralelogramoEspejo]; for(i=0;i<figuras.length;i++) { var figurita=figuras[i]; console.log(figurita); figurita.on('click', function() { figurita.setShadowBlur(8); figurita.setShadowColor("black"); figurita.setShadowOffset(3); figurita.setShadowOpacity(0.7); stage.add(layer); }); but this works perfectly: trianguloG1.on('click', function() { trianguloG1.setShadowBlur(8); .... Commented Jul 17, 2013 at 8:58
  • @Gozacid: I think you need to redraw the layer or something along those lines... Commented Jul 17, 2013 at 8:59
  • layer.draw() I think... The layer is already in your stage right? Commented Jul 17, 2013 at 9:00
  • yes: stage.add(layer); is included in click event. The problem is only using the array. if I use objects one to one works ok Commented Jul 17, 2013 at 9:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.