Hi everyone!
I have a JSON file with over 200 records.
I want every record to be active button with unique actions.
The code is the below:
$.getJSON("content.json",
function(data){
for(var i=0; i<200; i++){
var s = sym.getSymbol("base").createChildSymbol("template", "conts");
s.getSymbolElement();
s.element.attr('id', 'symbol'+i);
s.$("imageholder").css({"background-image":"url('"+data[i]. image+"')" });
s.$("imageholder").data('myIndex', i);
s.$("imageholder").data('title',data[i].name);
s.$("imageholder").click("click", function(e){
if ($(this).data("myIndex") == 0){
WB = 10;
sym.$("#symbol0").show();
sym.$("#symbol1").hide();
sym.$("#symbol2").hide();
sym.$("#symbol3").hide();
sym.getComposition().getStage().getSymbol('placer').$("holder").css({"background-image":" url("+$(this).data('Large')+")"});
sym.getComposition().getStage().getSymbol('placer').$("holdertxt").html($(this).data('tit le'));
if ( WB == 10) {
sym.getSymbol("#symbol0").$("rect").animate({opacity:1},700);
};
}
else if ($(this).data("myIndex") == 1) {
WB = 11;
sym.$("#symbol0").hide();
sym.$("#symbol1").show();
sym.getComposition().getStage().getSymbol('placer').$("holder").css({"background-image":" url("+$(this).data('Large')+")"});
sym.getComposition().getStage().getSymbol('placer').$("holdertxt").html($(this).data('tit le'));
if ( WB == 11) {
sym.getSymbol("#symbol1").$("rect").animate({opacity:1},700);
};
}
});
s.$("imageholder").mouseout ("mouseout",function(e){
if ($(this).data("myindex") == 0 && WB != 10) {
sym.getSymbol("#symbol0").playReverse("selectend");
}
else if ($(this).data("myindex") == 1 && WB != 11) {
sym.getSymbol("#symbol1").playReverse("selectend");
}
}
});
s.$("imageholder").mouseout ("mouseout",function(e){
if ($(this).data("myindex") == 0 && WB != 10) {
sym.getSymbol("#symbol0").play("selectstart");
}
else if ($(this).data("myindex") == 1 && WB != 11) {
sym.getSymbol("#symbol1").play("selectstart");
}
});
}
});
How is possible to place an each command or something else in order not to write for each Index and for each function the actions?
Now I am writing for every function of (mouseover, click, mouseout) the actions that every record of the JSON should make.
Can someone help me?