Quantcast
Channel: Adobe Community : All Content - Edge Animate
Viewing all articles
Browse latest Browse all 9897

retrieve variable value from local Storage and display on canvas

$
0
0

Hi

I'm working on a project that has multiple html files (the projects are split into 12 so 12 different edge projects and im linking them via window.open()). I have a variable that keeps track of correct answers stored in LocalStorage html object. I have managed to get the localStorage variable to increment up by one each time the object is correct however my last step is to get the variable and them display the result on the canvas. I have tried

 

var outPut localStorage.getItem(' ') method to retrieve the variable then used the set and get method to display the result however it doesn't work. Im not sure if I need a for loop to go though the localStorage and get the elements

 

Code:

 

// insert code to be run when the composition is fully loaded here

yepnope({nope:['jquery-ui-1.10.0.custom.min.js','jquery.ui.touch-punch.min.js'],complete: init}); // load the jquery files
sym.setVariable("myScore", 0);


var c = localStorage["myCount"] || 0; //loading from localStorage

function init(){

sym.getSymbol("barLimit").$('scrubber').draggable({start: function(e){


},drag: function(e,ui){ // start: ...  // Find original position of dragged image


var leftLimitScrubber  = sym.getSymbol('barLimit').$('scrubber').position().left; // position of the scrubber
var rightLimitScrubber  = sym.getSymbol('barLimit').$('leftLimit').position().left;

var LimitTwoLeft  = sym.getSymbol('barLimit').$('rightLimit').position().left;


if(leftLimitScrubber == rightLimitScrubber){
  sym.getSymbol('correctBar1').play('in'); //
  sym.getSymbol('nextButton').play('in');
  sym.getSymbol('incorrectBar1').play('out'); //
  sym.getSymbol('thumbsDown1').play('out'); //
  sym.getSymbol('thumbsUp1').play('in'); //
  sym.getSymbol('congrats').play('in'); //

localStorage["myCount"] = parseInt(c)+1; //Converting string to number, and then saving it
console.log("numberOfCorrectAnswers", localStorage["myCount"]);

var finalScore = sym.getVariable("myScore");
finalScore = c;
sym.setVariable("myScore", finalScore);
sym.$("Score").html(finalScore);

 

} else if(leftLimitScrubber == LimitTwoLeft){
sym.getSymbol('incorrectBar1').play('in');
sym.getSymbol('correctBar1').play('out');
sym.getSymbol('thumbsUp1').play('out');
sym.getSymbol('thumbsDown1').play('in');

 

}

},


axis: "x",
containment: "parent"
});

 

 

 


       //for (var i = 0; i < localStorage.length; i++){ // iterate throught the local storage
         //var getItem = localStorage.getItem(localStorage.key(i));
          //if(getItem == 'numberOfCorrectAnswers' ){


          //}
      //}

 

 

}

 

 

 

The above is the code for the 12th project in  this projects it needs to display the variable inside the object localStorage and display on the canvas.

Any help will mean a lot. Thank You in advance

 

P.S edge animate has a lot of bugs hard to code in


Viewing all articles
Browse latest Browse all 9897

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>