Share
Go down
Leo
Moderator
Moderator
Age : 21
Number of posts : 9201
Registration date : 2009-05-23
Location : Brazil
View user profile

automated textboxes (AS2) Empty automated textboxes (AS2)

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:
automated textboxes (AS2) KkBoPs4


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:
automated textboxes (AS2) FGjW7XV


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:
automated textboxes (AS2) 5u8gfwe


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:
automated textboxes (AS2) MgWviJU


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:
automated textboxes (AS2) K9ZsROf



did this kinda fast, so if you have any problems, feel free to tell me!
Similuo
Spritan
Spritan
Age : 25
Number of posts : 627
Registration date : 2013-11-03
Location : Hyrule Castle
View user profilehttps://twitter.com/tjcallwoodhttps://www.facebook.com/TJ Callwood

automated textboxes (AS2) Empty Re: automated textboxes (AS2)

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.

___________________________________________________________________________________________

automated textboxes (AS2) Tumblr_mcsjijhAEW1qzd219o1_500
Patt
Administrator
Administrator
Age : 24
Number of posts : 13138
Registration date : 2009-03-28
View user profile

automated textboxes (AS2) Empty Re: automated textboxes (AS2)

on 1/8/2014, 2:15 pm
Yay! Action script stuff!

Well done man.

___________________________________________________________________________________________

automated textboxes (AS2) Purple11

[The Return]
Ping
Spritan
Spritan
Age : 23
Number of posts : 20163
Registration date : 2010-09-15
Location : Madison Wisconsin
View user profile

automated textboxes (AS2) Empty Re: automated textboxes (AS2)

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! (:

___________________________________________________________________________________________

automated textboxes (AS2) Ping10
@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
Rapidfir3Pho3nix
Administrator
Administrator
Age : 25
Number of posts : 4867
Registration date : 2009-01-23
Location : Hollow Bastion
View user profilehttps://www.youtube.com/channel/UC0ntn5nE-2rEXLA8GQ7mtsAhttps://rapidfir3pho3nix.deviantart.com/https://discordapp.com/channels/142444698311589888/142444698311589888https://twitter.com/rapidfir3animshttps://www.facebook.com/Rapidfir3Pho3nix/https://www.twitch.tv/rapidfir3pho3nix

automated textboxes (AS2) Empty Re: automated textboxes (AS2)

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.
Leo
Moderator
Moderator
Age : 21
Number of posts : 9201
Registration date : 2009-05-23
Location : Brazil
View user profile

automated textboxes (AS2) Empty Re: automated textboxes (AS2)

on 1/11/2014, 6:07 pm
yeah, before i thought this was really hard to pull off. fortunately i was wrong
YoshiSonic
Spritan
Spritan
Age : 21
Number of posts : 1302
Registration date : 2010-11-05
Location : Earth
View user profile

automated textboxes (AS2) Empty Re: automated textboxes (AS2)

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.

___________________________________________________________________________________________

automated textboxes (AS2) Dancing-happy-yoshiautomated textboxes (AS2) 259ab217
Leo
Moderator
Moderator
Age : 21
Number of posts : 9201
Registration date : 2009-05-23
Location : Brazil
View user profile

automated textboxes (AS2) Empty Re: automated textboxes (AS2)

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
YoshiSonic
Spritan
Spritan
Age : 21
Number of posts : 1302
Registration date : 2010-11-05
Location : Earth
View user profile

automated textboxes (AS2) Empty Re: automated textboxes (AS2)

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.

___________________________________________________________________________________________

automated textboxes (AS2) Dancing-happy-yoshiautomated textboxes (AS2) 259ab217
Sponsored content

automated textboxes (AS2) Empty Re: automated textboxes (AS2)

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