Skip to main content
rudys98471852
Participant
April 11, 2019
Answered

Separate the letters of a word and put them in text areas

  • April 11, 2019
  • 1 reply
  • 303 views

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

    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    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

    1 reply

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    April 12, 2019

    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

    rudys98471852
    Participant
    April 12, 2019

    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 !

    JoãoCésar17023019
    Community Expert
    Community Expert
    April 12, 2019

    Excellent!

    You're welcome!