I am in the process of creating a cell phone simulation/animation in Edge Animate CC for use in a Captivate course. Basically, when a user clicks on number buttons on the virtual keypad, it displays the numbers in a text box , just like an actual cell phone would display the phone number on the screen as a caller is dialing. So, the user would click seven buttons and a seven-digit phone number appears on the virtual phone screen. This part of my animation works great and all seven digits appear, but I would like to modify the code so that a hyphen appears after the third button clicked. This way, the output better resembles an actual phone number instead of just a string of seven digits.
Here is an example of the code I currently have assigned to the #2 button on the virtual keypad:
var text = sym.$("PhoneNum").html();
text = text + 2;
PhoneNum is the name of my text box on the stage where the digits appear as each keypad button is clicked.
In order to incorporate the hyphen after the third button clicked, I need to somehow return the current number of characters in the PhoneNum text box, then create an if/else scenario that applies the hyphen after the third button clicked.
This solution worked great! Thank you!
Basically the thing to remember is that unless you are needing to pass html to the object, you can use text() instead. text() also gives you the raw text without any html formatting (so you can assume what .html() would return)