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, 2: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
    Location : Brazil
    Custom Rank : "Dank Memes." - Albert Einstein

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

    Re: automated textboxes (AS2)

    Post by Similuo on 12/31/2013, 3: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 : 22
    Number of posts : 627
    Registration date : 2013-11-03
    Location : Hyrule Castle

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

    Re: automated textboxes (AS2)

    Post by Patt on 1/8/2014, 4: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

    View user profile Pattiasina24
    avatar
    Eternal Spritan
    Eternal Spritan

    Re: automated textboxes (AS2)

    Post by Ping on 1/8/2014, 6: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
    Location : Madison Wisconsin

    View user profile Pingboi
    avatar
    Administrator
    Administrator

    Re: automated textboxes (AS2)

    Post by Rapidfir3Pho3nix on 1/11/2014, 7: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 : 4975
    Registration date : 2009-01-23
    Location : Hollow Bastion
    Custom Rank : wut

    View user profile
    avatar
    Moderator
    Moderator

    Re: automated textboxes (AS2)

    Post by Leo on 1/11/2014, 8: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
    Location : Brazil
    Custom Rank : "Dank Memes." - Albert Einstein

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

    Re: automated textboxes (AS2)

    Post by YoshiSonic on 1/11/2014, 8: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
    Location : Earth

    View user profile
    avatar
    Moderator
    Moderator

    Re: automated textboxes (AS2)

    Post by Leo on 1/11/2014, 8: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, 9:21 pm; edited 1 time in total
    avatar
    Leo
    Moderator
    Moderator

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

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

    Re: automated textboxes (AS2)

    Post by YoshiSonic on 1/11/2014, 9: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
    Location : Earth

    View user profile
    Sponsored content

    Re: automated textboxes (AS2)

    Post by Sponsored content


    Sponsored content


    Reply to topic

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

    Remember me: I forgot my password

    Who is online?
    None

    In total there are 10 users online :: 0 Registered, 0 Hidden and 10 Guests :: 1 Bot

    [ View the whole list ]

    Staff Online
    Latest topics
    The Spritas Discord Channel