How do I inplement javascript $each() in C2?

Get help using Construct 2

Post » Thu Jan 26, 2017 3:20 pm

In the example below in Edge Animate*, a different image is loaded according to what button is clicked. How could I implement that in C2?
* Edge Animate uses a slightly modified javaScript where sym is the stage symbol. The individual button elements are all children of the div.

I do not seem to find a way to address a series of buttons in this way.

Code: Select all
var buttons = sym.$("buttons").children();     

$.each(buttons,function(i){
   $(this).on("click", function(){
         // do something when one of the button is clicked   
         sym.$("images").css({"opacity":0.00});
         sym.$("images").animate({"opacity":1.00},700).attr('src',"images/image" + i + ".png");            
   });   
})
B
8
S
1
Posts: 86
Reputation: 618

Return to How do I....?

Who is online

Users browsing this forum: R0J0hound, RobertMKD, Syazanie Amirin and 10 guests