Skip to main content
Participating Frequently
Jun 28, 2022 7:48 AM UTC
Answered

Letter limit and move to other box Adobe Animate HTML5 Canvas

What do I need to do to get only 1 letter written?

What should I do to switch to the next box after typing?

 

 

 

    This topic is closed to new replies. Start a new post to keep the conversation going.
    kglad
    kgladCorrect answer
    Community Expert
    Jun 29, 2022 2:12 PM UTC

    Is this the only place I would name the code based on my project? because i am getting error

     




    that's my error.  focusA != this.focusA, so 

     

    for(var i=0;i<focusA.length;i++){

     

    should be

     

    for(var i=0;i<this.focusA.length;i++){

    7 replies

    kglad
    Community Expert
    Community Expert
    Jun 28, 2022 1:11 PM UTC

    what determines the end of typing? (eg, the enter key press)

    what's the instance name of the "next" textfield?

    are those dynamic textfields?

    are you listening for keyboard events and then adding text using js?

    Translate
    Participating Frequently
    Jun 28, 2022 2:55 PM UTC

    No problem thanks,

    but What do I need to do to get only 1 letter written?

    (textinput)

    Translate
    kglad
    Community Expert
    Community Expert
    Jun 28, 2022 5:39 PM UTC

    that's a mistake.  (using a textinput component.)  as mentioned before you should be using a dynamic textfield.

     

    but if that's what you want, this will do what you want and set you up to continue to the next problem:

     

    this.focusA = [];

    document.addEventListener('keyup', f.bind(this));

    function drawEndF(){
    this.focusA.push(document.getElementById("ti_1"));  // where ti_1 is a text input component.  you'll want to loop through them all here
    }


    stage.on("drawend", drawEndF, this, true);

     

    function f(e){
    for(var i=0;i<focusA.length;i++){
    if(this.focusA[i] == document.activeElement){
    this.focusA[i].value = this.focusA[i].value.slice(-1);
    }
    }
    }

    Translate