2 Replies Latest reply on Nov 19, 2014 10:15 AM by resdesign

    Changing image by mouseclick

    singleston Level 1

      How do I change my image to another one on mouse click ? Thanks in advance

        • 1. Re: Changing image by mouseclick
          vivekuma Adobe Employee

          Try this:

               sym.$("elementName").css({"background-image":"url(images/otherImage.jpg)"});

           

          hth,

          Vivekuma

          • 2. Re: Changing image by mouseclick
            resdesign Adobe Community Professional & MVP

            I may add that there a 2 ways of changing images. If all your images are the same size then place 1 on the stage and change from div to img. then you can use:

            Here I assume you go through an array on your click event:

            sym.$('imageName").attr("scr","images/"+ arrayName[i]+".jpg");

             

            and as Vivekuma said if you have images that are different size - use an empty did and change the background.

            sym.$("image").attr("src", "images/image" + arrayName[i]+ ".png");

             

            I will choose whatever makes more sense in my project.