Copy link to clipboard
Copied
Hi All,
I'm using Animate CC to build an HTML5<canvas> final product.
Again, I'm still learning the terminology so I can do effectively search for answers. This one is eluding me:
How do I convert a string, like "myInstanceName" to something I can use (as the name of the instance) in a line of code like:
Thanks much!
an instance name is not a string so you can use it just like colin indicated.
but if you have a string, you would use:
this[myString].addEventListener('click',myFunction.bind(this));
Copy link to clipboard
Copied
Stage is perhaps not the same location as where myInstanceName is. This should work:
this.myInstanceName.addEventListener("click", myFunction.bind(this));
Copy link to clipboard
Copied
an instance name is not a string so you can use it just like colin indicated.
but if you have a string, you would use:
this[myString].addEventListener('click',myFunction.bind(this));
Copy link to clipboard
Copied
Yes, Kglad.
I do have a string and that "this[myString].addEventListener..." works.
Thanks much!
Thanks also, Colin.
Copy link to clipboard
Copied
you're welcome.
Copy link to clipboard
Copied
All there in the manual...
Copy link to clipboard
Copied
Thanks ClayUUID
good resource.