19 Replies Latest reply on May 18, 2010 11:14 AM by kglad

    flash newbie needs help

    mrmuffin92

      i'm quite a newbie when it comes to flash and need some help

       

      http://www.sas.se/sv/?vst=true

       

      you look to the right you'll see an airplane and i'll say "Billiga avgångar" next too it

      under the text you can see text in yellow being scrambled then reappear

       

      i was wondering how you make the text scramble then display the messeage like that?

        • 1. Re: flash newbie needs help
          Ned Murphy Adobe Community Professional & MVP

          It appears as though there might be 2 or 3 textfields for each animated line.  One left justified which eventually displays after the scrambling completes, and the other (1 or 2) right justified which first probably does some form of gradual random animation of decreasing length characters which appear to scramble and gradually reduce to the right side where the number finally appears at the end of the scrambling.

           

          So you want to consider using the Math.random() method to randomly select characters in some form of enterFrame activity which gradually reduces the length of the characters for each cycle.

          • 2. Re: flash newbie needs help
            mrmuffin92 Level 1

            as you can imagine being a noob i don't have a really big idea of what you're talking about is their any guide for dummies on this ?

            • 3. Re: flash newbie needs help
              kglad Adobe Community Professional & MVP

              this is a better way to do it in one textfield.  it's easily amended to display one letter per textfield and add textfields as needed.

               

              (to speed up the display shorten charS even down to a one character string.)

               

              var charS:String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 01232456789,./<>?;':\"[]{}\|!@#$%^&*()-_=+";
              var charA:Array = charS.split("");
              var displayTO:Number

               

              // user defined params:
              // character change in ms
              var speed:Number = 1;

               

              encodeF(yourstring,yourtextfield);

               

              function encodeF(s:String,tf:TextField){
                  tf.text = charA[0];
                  displayTO = setTimeout(displayF,speed,s,tf,0,0);
              }

               

              function displayF(s:String,tf:TextField,charNum:Number,index:Number){
                  tf.text = tf.text.substr(0,-1)+charA[index];
                  if(s.charAt(charNum)==charA[index]){
                      tf.text += charA[index];
                      charNum++;
                      index=0;
                      if(charNum<s.length){
                          displayTO = setTimeout(displayF,speed,s,tf,charNum,index);
                      } else {
                          tf.text = tf.text.substr(0,-1);
                      }
                  } else {
                      index++;
                      if(index<charA.length){
                          displayTO = setTimeout(displayF,speed,s,tf,charNum,index);
                      } else {
                          charA.push(s.charAt(charNum));
                          displayTO = setTimeout(displayF,speed,s,tf,charNum,index);
                      }
                  }
              }

              1 person found this helpful
              • 4. Re: flash newbie needs help
                Ned Murphy Adobe Community Professional & MVP

                I'm not talking in terms of code as much as just an approach, so if you can't understand an approach, then your less likely to grasp a solution in code.  Still, you can take what kGlad has offered and work it thru with him.  I was going to mention, but forgot, that there are probably alot of ways to approach this... the key to finding your own is to observe what is going on and try think it thru.

                • 5. Re: flash newbie needs help
                  mrmuffin92 Level 1

                  well this is for school and i don't really have time to learn code before the deadline but i've done some research and it seems you can do this with keyframe and motion tween? i want it too dissaper - scramble - appear. think anyone could explain it?

                  • 6. Re: flash newbie needs help
                    kglad Adobe Community Professional & MVP

                    that would be a mess and just about impossible with timeline tweening. 

                     

                    just copy and paste the code i suggested.

                    1 person found this helpful
                    • 7. Re: flash newbie needs help
                      mrmuffin92 Level 1

                      yeaa now i feel bad about failing to apply it :I think you could be so kind to guide be throught it? just copy & pasta  is not working

                      just shows the code as a text

                       

                       

                      running actionscript 2.0 with flash player 10

                      • 8. Re: flash newbie needs help
                        kglad Adobe Community Professional & MVP

                        do you have a textfield on stage?  if not, create one and give it an instance name (eg tf).  if yes, give it an instance name (eg, tf).

                         

                        then leave all the code unchanged except for:

                         

                        encodeF(yourstring,yourtextfield);

                         

                        change that line to:

                         

                        encodeF("this is a test",tf);

                        • 9. Re: flash newbie needs help
                          mrmuffin92 Level 1

                          assuming i did this right it's not working so i loaded my image pressed f9 selected scene 1 copy & pasta the code did the change in the code and i got

                           

                           

                          1120: Access of undefined property tf.

                          Warning: 3551: Appending text to a TextField using += is many times slower than using the TextField.appendText() method.

                          • 10. Re: flash newbie needs help
                            kglad Adobe Community Professional & MVP

                            your publish settings are for as3.  which do you want to use, as2 or as3?

                             

                            and, what do you mean by, "..i loaded my image.."?  what image?

                             

                            and, add a textfield.

                            • 11. Re: flash newbie needs help
                              kglad Adobe Community Professional & MVP

                              here:  www.kglad.com/Files/forums/Untitled-5.fla

                              • 12. Re: flash newbie needs help
                                mrmuffin92 Level 1

                                yes, that looks quite nice what i meant by imagie is that i've made a photo in photoshop and i wanted the code to scramble each layer of text i addded suppos that is possible? i guess if not i could work something out from the textbox but then i would need to remove the borders

                                • 13. Re: flash newbie needs help
                                  mrmuffin92 Level 1

                                  nvm previous post.. i was wondering is it possible to set encodeF("Billiga Avgångar",tf); too display in the middle of the screen instead of to the far left maybe som align command? also how do you create a new row tried:

                                   

                                   

                                  encodeF("testr",tf);

                                  encodeF("testr",tf);
                                  just wrote it on the first one
                                  • 14. Re: flash newbie needs help
                                    kglad Adobe Community Professional & MVP

                                    move the textfield wherever you want.  i placed it on-stage in the authoring environment.

                                     

                                    and use as many textfields as you want.  that's what i meant by this being a better way:  you can simultaneously apply that effect to any number of textfields.

                                    • 15. Re: flash newbie needs help
                                      mrmuffin92 Level 1

                                      well if i use more then 1 textfield it will look kinda fishy if the borders are still there anyway to get rid of them? and how do i get colored text ?

                                      • 16. Re: flash newbie needs help
                                        kglad Adobe Community Professional & MVP

                                        you can control both properties in the authoring environment (using the properties panel) or with actioncript.

                                        • 17. Re: flash newbie needs help
                                          mrmuffin92 Level 1

                                          oki awesome, just one final thing i tried to copy pasta the textbox to have multiple once allthought only the pasted textbox shows the scramble?

                                          • 18. Re: flash newbie needs help
                                            mrmuffin92 Level 1

                                            nvm apperntly all you need to do is add

                                             

                                             

                                                tf.text = tf.text.substr(0,-1)+charA[index];

                                             

                                            and change tf.text to tf1.text and then the textfield to that name aswell and you can have as many as you want thanks for the help mate
                                            • 19. Re: flash newbie needs help
                                              kglad Adobe Community Professional & MVP

                                              you don't need and shouldn't change anything in any of the function bodies.  tf is a function parameter.