Font size for TextInput component in Animate CC HTML5 Canvas
I'm converting Flash animations to HTML5 Canvas in Animate CC. How do I change the font size and font for a TextInput component?
I'm converting Flash animations to HTML5 Canvas in Animate CC. How do I change the font size and font for a TextInput component?
Hi.
Here is one way of doing it:
- You use a setTimeout method to make sure the component it's ready to be referenced in the beginning;
- Access the div element called dom_overlay_container created by Animate CC that holds all DOM based components (e.g.: TextInput and CheckBox).
- Then use bracket notation to reference the instance name of your component in the children property;
- Finally, you can set any valid CSS property through the JavaScript style property.
Like this:
var textInput;
setTimeout(function()
{
// dom_overlay_container is a global reference to a div element created by Animate CC. "txt" is the instance name of your component
textInput = dom_overlay_container.children["txt"];
textInput.style.fontSize = "28px";
textInput.style.fontFamily = "'Comic Sans MS', cursive, sans-serif";
}, 0);
Regards,
JC
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.