Copy link to clipboard
Copied
I hava a MC on stage with the instance name "lcars1" wich consists of a SVG. When I use the following code to change the color randomly every 3 seconds:
setInterval(function(){
var randomColor1 = "#" + Math.floor(Math.random()*16777215).toString(16);
this.lcars1.style.fill = randomColor1;
}, 3000);
the browser returns this error message: "Cannot read property 'style' of undefined"
According to my recherche here at the forum and at Stack Overflow several Adobe customers
have a similar issue like me at Animate CC and do not know how to add their Element to the scope, respectively how to target a SVG or bitmap within a Movie Clip in Html5/Canvas with JavaScipt.
I received an insinuation of an answer from someone, who said I shall use the .bind method to make the MC respectively it's content avaiable to the scope, but did not provide any syntax on how to do that exactly. The result was I searched for hours at all the internet without any success.
I want to create a tutorial website about the solution for Animate CC. Please support that tutorial by providing the solution. If you do so and tell me, that you want to be named and credited at the tutorial for providing that essential knowledge for targeting elements dynamically I am thankful to do you that favour.
Kind Regards
Felix Czeck
Have something to add?