https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
HomeHome  
  • HomeHome  
  • Forums  
  • MemberlistMemberlist  
  •  
  • FAQFAQ  
  • SearchSearch  
  • UsergroupsUsergroups  
  • RegisterRegister  
  • Log inLog in  

  • Reply to topic
    avatar
    Moderator
    Moderator

    automated textboxes (AS2)

    Post by Leo on 12/31/2013, 12:58 am

      hi again
      got a few requests on how to do this, so here it goes. won't really explain the code in detail, as i don't feel like doing that. just google "typewriter effect" or whatever, if you really want to know.

      Step 1
      create your dynamic text box and give it the instance name of "text_txt" (without the quotes, obviously)
      Spoiler:


      Step 2
      create the graphic for your textbox. i'm lazy so i'll just use a black rectangle here, but you can be as fancy as you want. you can also just grab one from a game or something
      Spoiler:


      Step 3
      take both the text and the graphic and put those in a movieclip. then give it the instance name of "textHolder". the reason i'm doing this is so that i can just drag this symbol from the library, whenever i need to use it, instead of copy-pasting these everytime. that and if i use the automated parallax code on my animation, i can apply it to this as well (won't cover how to do it here though) (yeah i'm really lazy)
      Spoiler:


      Step 4
      then copy and paste this code on the frame you want to use this (the little animation i did was for clarity - so you could see it looping and whatnot):
      Code:
      var contentField:String = "change this to your text";
      var charLength:Number = length(contentField);
      var charNr:Number = 0;
      var charNr2:Number = 0;
      var speed:Number = 20;//milliseconds
      function showChar():Void {
        if (charNr<charLength) {
           charNr++;
           _root.textHolder.text_txt.text = contentField.substr(0, charNr);
           _root.textHolder.text_txt.setTextFormat(my_fmt);
        } else {
           clearInterval(showCharX);
        }
      }
      var showCharX:Number = setInterval(showChar, speed);
      clearInterval(showCharDelayX);
      Spoiler:


      Step 5 (optional)
      if you want to add sound to this, then give the sound an identifier (can be whatever name you want, but here i'm using "soundText"), then change the code to this:
      Code:
      var contentField:String = "change this to your text";
      var charLength:Number = length(contentField);
      var charNr:Number = 0;
      var charNr2:Number = 0;
      var speed:Number = 20;//milliseconds
      function showChar():Void {
        if (charNr<charLength) {
           charNr++;
             var typing_sound = new Sound(this);
             typing_sound.attachSound("soundText");
      //soundText is the identifier
             typing_sound.start(0, 1);
           _root.textHolder.text_txt.text = contentField.substr(0, charNr);
           _root.textHolder.text_txt.setTextFormat(my_fmt);
        } else {
           clearInterval(showCharX);
        }
      }
      var showCharX:Number = setInterval(showChar, speed);
      clearInterval(showCharDelayX);
      additionally, if you DO use a sound, then make sure its volume is low, because if it gets repeated a lot it adds up and gets really loud. that and it would be annoying. so keep its volume low.
      Spoiler:



      did this kinda fast, so if you have any problems, feel free to tell me!
      avatar
      Leo
      Moderator
      Moderator

      Age : 19
      Number of posts : 9196
      Registration date : 2009-05-23
      Rep : 3
      Location : Brazil
      Custom Rank : "Dank Memes." - Albert Einstein

      View user profile
      avatar
      Preschool Spritan Lv 3
      Preschool Spritan Lv 3

      Re: automated textboxes (AS2)

      Post by Similuo on 12/31/2013, 1:21 am

        Damn talk about an enhanced tutorial without all the annoying YouTube stuff. Thanks Leo, this is really helpful.



        avatar
        Similuo
        Preschool Spritan Lv 3
        Preschool Spritan Lv 3

        Age : 23
        Number of posts : 627
        Registration date : 2013-11-03
        Rep : 0
        Location : Hyrule Castle

        View user profile https://www.facebook.com/TJ Callwood https://twitter.com/tjcallwood
        avatar
        Administrator
        Administrator

        Re: automated textboxes (AS2)

        Post by Patt on 1/8/2014, 2:15 pm

          Yay! Action script stuff!

          Well done man.





          [The Return]
          avatar
          Patt
          Administrator
          Administrator

          Age : 21
          Number of posts : 13107
          Registration date : 2009-03-28
          Rep : 9

          View user profile
          avatar
          Eternal Spritan
          Eternal Spritan

          Re: automated textboxes (AS2)

          Post by Ping on 1/8/2014, 4:09 pm

            I found this very thorough and beneficial. This tutorial provides good highlights to action scripting. The sound option proves that exemplary. Thanks Leo! (:




            @darkdragon581 wrote:ping, i don't see you getting 'boodie' anytime soon, i don't care if your black, its most likely not going to happen
            avatar
            Ping
            Eternal Spritan
            Eternal Spritan

            Age : 21
            Number of posts : 20163
            Registration date : 2010-09-15
            Rep : 8
            Location : Madison Wisconsin

            View user profile
            avatar
            Administrator
            Administrator

            Re: automated textboxes (AS2)

            Post by Rapidfir3Pho3nix on 1/11/2014, 5:21 pm

              Your tutorials are so high quality! This is awesome.

              Also, I never realized how simple this code actually was, holy shit.
              avatar
              Rapidfir3Pho3nix
              Administrator
              Administrator

              Age : 22
              Number of posts : 4992
              Registration date : 2009-01-23
              Rep : 60
              Location : Hollow Bastion
              Custom Rank : wut

              View user profile
              avatar
              Moderator
              Moderator

              Re: automated textboxes (AS2)

              Post by Leo on 1/11/2014, 6:07 pm

                yeah, before i thought this was really hard to pull off. fortunately i was wrong
                avatar
                Leo
                Moderator
                Moderator

                Age : 19
                Number of posts : 9196
                Registration date : 2009-05-23
                Rep : 3
                Location : Brazil
                Custom Rank : "Dank Memes." - Albert Einstein

                View user profile
                avatar
                Elementary Spritan Lv 2
                Elementary Spritan Lv 2

                Re: automated textboxes (AS2)

                Post by YoshiSonic on 1/11/2014, 6:44 pm

                  You should do the Parallax code next meng, it's really confusing, but eh, doing it by yourself works also.



                  avatar
                  YoshiSonic
                  Elementary Spritan Lv 2
                  Elementary Spritan Lv 2

                  Age : 18
                  Number of posts : 1302
                  Registration date : 2010-11-05
                  Rep : 0
                  Location : Earth

                  View user profile
                  avatar
                  Moderator
                  Moderator

                  Re: automated textboxes (AS2)

                  Post by Leo on 1/11/2014, 6:53 pm

                    the parallax code is really easy (and kind of weird with zooms, but it will do because no one has a better engine, except for lange but ITS LANGE)
                    basically, you just give your vcam the instance name of vcam, then click on the bg movieclip that you want to apply the parallax and write this (AS2)
                    Code:
                    onClipEvent(enterFrame){
                       this._x = _root.vcam_x;
                       this._y = _root.vcam_y;
                       this._xscale = _root.vcam_xscale;
                       this._yscale = _root.vcam_yscale;
                    }
                    that's if you want it to be static. if you want it to move then it's more like
                    Code:
                    onClipEvent(enterFrame){
                       this._x = _root.vcam_x*0.8;
                       this._y = _root.vcam_y*0.8;
                       this._xscale = _root.vcam._xscale;
                       this._yscale = _root.vcam._yscale;
                    }

                    and you can change the 0.8 to something else. the closer it is to 1, the less it moves.


                    Last edited by Leo on 1/11/2014, 7:21 pm; edited 1 time in total
                    avatar
                    Leo
                    Moderator
                    Moderator

                    Age : 19
                    Number of posts : 9196
                    Registration date : 2009-05-23
                    Rep : 3
                    Location : Brazil
                    Custom Rank : "Dank Memes." - Albert Einstein

                    View user profile
                    avatar
                    Elementary Spritan Lv 2
                    Elementary Spritan Lv 2

                    Re: automated textboxes (AS2)

                    Post by YoshiSonic on 1/11/2014, 7:02 pm

                      @Leo wrote:the parallax code is really easy (and kind of weird with zooms, but it will do because no one has a better engine, except for lange but ITS LANGE)
                      basically, you just give your vcam the instance name of vcam, then click on the bg movieclip that you want to apply the parallax and write this (AS2)
                      Code:
                      onClipEvent(enterFrame){
                         this._x = _root.vcam_x;
                         this._y = _root.vcam_y;
                         this._xscale = _root.vcam_xscale;
                         this._yscale = _root.vcam_yscale;
                      }
                      that's if you want it to be static. if you want it to move then it's more like
                      Code:
                      onClipEvent(enterFrame){
                         this._x = _root.vcam_x*0.8;
                         this._y = _root.vcam_y*0.8;
                         this._xscale = _root.vcam_xscale;
                         this._yscale = _root.vcam_yscale;
                      }

                      and you can change the 0.8 to something else. the closer it is to 1, the less it moves.


                      By instance name do you mean--

                      Wait I don't want to flood this thread with you helping me. I'll pm you.



                      avatar
                      YoshiSonic
                      Elementary Spritan Lv 2
                      Elementary Spritan Lv 2

                      Age : 18
                      Number of posts : 1302
                      Registration date : 2010-11-05
                      Rep : 0
                      Location : Earth

                      View user profile
                      Reply to topic

                       
                      Permissions in this forum:
                      You cannot reply to topics in this forum

                      Your last visit was on

                      Current date/time is 4/26/2017, 12:56 am

                      Log In

                      Remember me: I forgot my password

                      Who is online?
                      None

                      In total there are 18 users online :: 0 Registered, 0 Hidden and 18 Guests :: 2 Bots

                      [ View the whole list ]

                      Staff Online
                      Latest topics
                      Killer Instinct
                      by Rapidfir3Pho3nix Yesterday at 5:33 pm

                      The Spritas Update #2
                      by Rapidfir3Pho3nix Yesterday at 5:23 pm

                      FSSJ vs. LCSSJ Gohan
                      by SonicTFS 4/22/2017, 8:51 am

                      Mario's Goal Calamity Collab
                      by Wiki 4/19/2017, 1:09 pm

                      The Spritas Discord Channel
                      Donate

                      Want to help out the site? Donating helps ensure the site is running as smoothly as possible! You may donate through PayPal using the button below.