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

Randomize color every N seconds

$
0
0

Hello Everyone!

 

I'm new to the forum and to Edge Animate. I've worked before with Flash (actionscript), (a little) javascript and processing and some web design but I'm having issues wrapping my head around the workflow in Edge.

 

Basically what I'm trying to do is to randomly change the fill/background color of a square (a symbol) inside my composition using variables for R, G and B and a timing event (JS setInterval method). I think i have a syntax issue but I'm not sure where. Any help would be appreciated, here is the code: (it's on the first frame of document.compositionReady):

 

//create variables for R G B
var randR;
var randG;
var randB;


//var myVar = setInterval(function(){myTimer()},1000);


//setInterval method:  window.setInterval("javascript function", milliseconds);


//define the function randomColors()
var myVar = setInterval(
  function randomColors() {  randR = Math.floor(Math.random()*255);  randG = Math.floor(Math.random()*255);  randB = Math.floor(Math.random()*255);  myTimer();  },  1000);


//call the main function
randomColors();


//define the time-based function
function myTimer() {
    var d = new Date();  sym.$("mySquare").style.backgroundColor = rgb(randR,randG,randB);
}

 

 

Here is the file.

 

Thanks again! I hope I was clear enough. The reason why I want to do this is because later I would like to randomly load a video file into the composition every certain period of time, but I wanted to start with something simple.


Viewing all articles
Browse latest Browse all 9897

Trending Articles



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