Copy link to clipboard
Copied
Sorry for the mistakes of language. Text translated from French.
Hello !
I looked on the Internet, on the forums, I copied codes, but I did not succeed. Can you help me please?
Langage
html 5 JS Canvas
Context
First, I get back the current year. No problem
var myyear = new Date ();
var an = myyear.getFullYear ();
this.textyear.text = an;
Problem
I would like to put each retrieved number in a different text area to be able to animate them independently.
2 in a area text, 0 in a other area text, etc...
Thank's you very much
Hi.
Here is a suggestion. Basically turn the year into a string and assign each letter to a different text field.
JS code:
var year = String(new Date().getFullYear());
this.firstText.txt.text = year[0];
this.secondText.txt.text = year[1];
this.thirdText.txt.text = year[2];
this.fourthText.txt.text = year[3];
FLA download:
animate_cc_html5_canvas_year_to_text_fields.zip - Google Drive
Regards,
JC
Copy link to clipboard
Copied
Hi.
Here is a suggestion. Basically turn the year into a string and assign each letter to a different text field.
JS code:
var year = String(new Date().getFullYear());
this.firstText.txt.text = year[0];
this.secondText.txt.text = year[1];
this.thirdText.txt.text = year[2];
this.fourthText.txt.text = year[3];
FLA download:
animate_cc_html5_canvas_year_to_text_fields.zip - Google Drive
Regards,
JC
Copy link to clipboard
Copied
Hello JoãoCésar,
I am struck by the simplicity of the solution. And yet, I searched. I'll try to see the basics of the JS.
Thank you very much for the quick answer and for the file. You're very helpful !
Copy link to clipboard
Copied
Excellent!
You're welcome!