1 Reply Latest reply on Jan 21, 2013 5:45 AM by joel_pau

    code not working - please help ! (if else statement)

    ashleyren

      Hi,

       

      i'm new to edge and I'm trying to do a simple animation of a chart where there are 2 buttons and on clicking the buttons it animates each line in as a symbol using "play()".

       

      what i'm trying to add is a set of variables so that once you click the buttons each variable "greenclicked" and "redclicked" are set to 1 (changed from 0). it then checks using an IF/ELSE to see if you've already clicked the other button (set to 1) and if so it plays the symbol "revealer" timeline.

       

      i've tracked the JS error down to the IF statement, and i believe its to do with the condition but my javascript knowledge is limited so i'm not sure of the correct syntax.

       

      here's the code i'm using:

       

      ///////  ON COMPOSITION READY

      sym.getComposition().getStage().setVariable('greenclicked', "0");

      var i = sym.getComposition().getStage().getVariable('greenclicked');

      console.log ("greenclicked initialised at = "+i);

      //

      sym.getComposition().getStage().setVariable('redclicked', "0");

      var k = sym.getComposition().getStage().getVariable('redclicked');

      console.log ("redclicked initialised at = "+k);

       

      ///////  ON RED BUTTON CLICK

      sym.getSymbol("red_line").play();

      //

      sym.getComposition().getStage().setVariable('redclicked', 1);

      //

      var i = (sym.getComposition().getStage().getVariable('greenclicked'));

      //

      if (greenclicked==1){

          console.log("greenclicked = "+i+" - revealer triggered");

          sym.getSymbol("revealer").play();

      } else {

          console.log("red button revealer not triggered");

      };

       

      ///////  ON GREEN BUTTON CLICK

      sym.getSymbol("green_line").play();

      //

      sym.getComposition().getStage().setVariable('greenclicked', 1);

      //

      var k = (sym.getComposition().getStage().getVariable('redclicked'));

      //

      if (redclicked==1){

          console.log("redclicked = "+k+" - revealer triggered");

          sym.getSymbol("revealer").play();

      } else {

          console.log("green button revealer not triggered");

      };

       

      ----------------------------------

       

      The error i'm getting in the console is "[11:42:26.893] Javascript error in event handler! Event Type = element"

       

      Any help with this appreciated

       

      Thanks,

      Ash