5 Replies Latest reply on Oct 23, 2006 4:50 AM by duckets

    Typing Animation

    JustinHF
      I use director most for creating animations. I'm not great with scripting, i just use it for loops and key commands. What i'm trying to do now is create a "tech diagnostic" animation designed to look like a computer program analyzing something like DNA or Temperature or whatever. As the "program is analyzing i want lines of text to "type on" to show results of certain diagnostics. I'd like to be able to create a text member, type the text i need and then drop a behavior on it so that when the playhead hits that sprite, it types it out and stays on until the sprite ends. I've tried using Director's Typewriter behavior but the text comes on too slow and it allow more than one sprite to type on at the same time. Can anyone help me out?
        • 1. Re: Typing Animation
          Level 7
          Here ya go, I just knocked this behavior together. Should do what you need.
          Just place it on a text sprite and adjust the speed accordingly.



          property mySpeed, myText, myTimeout, charIndex


          on getPropertyDescriptionList
          pList = [:]
          addProp pList,#mySpeed,[#comment:"Milliseconds per letter:",#default:50,
          #format:#integer]
          return pList
          end


          on beginSprite me
          charIndex = 0
          myText = sprite(me.spriteNum).member.text
          sprite(me.spriteNum).member.text = ""
          myTimeout = timeout().new("charTimer", mySpeed, #nextLetter, me)
          end


          on nextLetter me
          charIndex = charIndex + 1
          if charIndex <= mytext.length then
          put myText.char[charIndex] after sprite(me.spriteNum).member
          else
          timeout("charTimer").forget()
          end if
          end


          on endSprite me
          sprite(me.spriteNum).member.text = myText
          end






          --
          Dave -
          Adobe Community Expert
          www.blurredistinction.com
          http://www.adobe.com/communities/experts/


          • 2. Re: Typing Animation
            JustinHF Level 1
            Thanks a lot for the reply. It works pretty well. There are a few problems with the way i want to use it and maybe director just can't do what i want. I tried run two of these at once and it won't let me. I staggered the sprites one after the other so that the first would start to type and then the second would come in. It starts out fine but when the second sprite starts the first one freezes. Can director run more than one script at a time? Another thing is if i'm working with the director file and start and stop before all of the letters type out then i loose the rest of my text and have to retype it. the last thing is that i would like it to go faster. It took the milliseconds down to 1 and still typed on pretty slow. I'd like one line of text (about 6 or 7 words long) to read on in about 6 frames. Thanks again for the help. If there's anything you can do or at least point me in the right direction i'd greatly appreciate it.

            justin
            • 3. Re: Typing Animation
              Level 7
              >> I tried run two of these at once and it won't let me.

              It will. You just need to change how the timeout object is named. Right now
              it's simply named "charTimer" - and timers are system objects. The next
              instance of the same named timer wipes out the old one. To fix this just
              name the timer with a unique name such as "charTimer" & string(me.spriteNum)

              >>Another thing is if i'm working with the director file and start and stop
              >>before all of the letters type out then i loose the rest of my text and
              >>have to retype it.

              That had to do with the non-unique timer objects. Should be fine now - the
              endSprite handler sets the text back, as you can see.

              I made a few modifications including taking 5 characters at a time which
              makes it appear to type out a lot faster.

              HTH


              property mySpeed, myText, myTimeout, charIndex, myTimerName


              on getPropertyDescriptionList
              pList = [:]
              addProp pList,#mySpeed,[#comment:"Milliseconds per letter:",#default:50,
              #format:#integer]
              return pList
              end


              on beginSprite me
              charIndex = -4
              myTimerName = "charTimer" & string(me.spriteNum)
              myText = sprite(me.spriteNum).member.text
              sprite(me.spriteNum).member.text = ""
              myTimeout = timeout().new(myTimerName, mySpeed, #nextLetter, me)
              end


              on nextLetter me
              charIndex = charIndex + 5
              if charIndex <= mytext.length then
              put myText.char[charIndex..charIndex+4] after
              sprite(me.spriteNum).member
              else
              timeout(myTimerName).forget()
              end if
              end


              on endSprite me
              sprite(me.spriteNum).member.text = myText
              end





              --
              Dave -
              Adobe Community Expert
              www.blurredistinction.com
              http://www.adobe.com/communities/experts/


              • 4. Re: Typing Animation
                Macnimation Level 1
                Hi,

                I know its been a while since this topic was dealt with but I hope you can help. I have inserted the above behaviour into a few text members and it works well.

                however, instead of it typing 5 characters at a time, I would like it to only type one at a time and control the speed using the millisecond option. i have tried adjusting a few of the parameter values like:

                charIndex = charIndex + 5

                and changing it to say

                charIndex = charIndex + 1

                But I get the whole text field repeated several times.

                Can you point out the correct values please as this behaviour you have created will save me hours?

                cheers
                • 5. Re: Typing Animation
                  duckets Level 1
                  You might be interested in using this alternative behaviour (linked to below). It types out text at any speed (you just specify characters per second), and it does it independent of the frame rate of your movie.

                  It also uses a temporary second member, which avoids the possible problem where if your movie was stopped without the 'endsprite' handler being called (for example, an error, or hitting ctrl + . ), your original text would be lost!

                  demo & source here:

                  http://robotduck.com/content/articles/director/visualEffects/typeOutText/


                  - Ben