Highlighted

How to target a SVG or Bitmap within a Movie Clip Html5/Canvas with JavaScipt dynamically?

New Here ,
Aug 17, 2020

Copy link to clipboard

Copied

for-forum.png

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

Views

6

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How to target a SVG or Bitmap within a Movie Clip Html5/Canvas with JavaScipt dynamically?

New Here ,
Aug 17, 2020

Copy link to clipboard

Copied

for-forum.png

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

Views

7

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 17, 2020 0

Have something to add?

Join the conversation