00:00
00:00
Newgrounds Background Image Theme

Ykj03 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

AS: Subtitles.

5,572 Views | 23 Replies
New Topic Respond to this Topic

AS: Subtitles. 2005-10-26 07:01:25


Pwnz j00 <-- AS: Main
_____________

AS: Variables by Rantzien
gotoAndStop(); by Inglor
AS: ClipEvents by Inglor

AS: Subtitiles

Part I: Necessary AS Knowledge
This tutorial is for beginners, you don't have to be a programmer to use it.
What you need to know is:

-Basic events.
-gotoAndPlay / gotoAndStop.
-"if" conditions.

Part II: Introduction
Hello again, newgrounders. Today you will learn how to create a simple subtitles system that can contain more than 10 languages! This won't be very long, no explanations needed for such a basic code.

WARNING: This tutorial will NOT teach you other languages, if you only speak english and you don't have a translator, this tutorial will be quite useless for you.

For the code examples I will be using english and french, feel free to change it.

There are two ways to make subtitles, I will be explaining both - Choose the one you prefer.

Part III: Getting started

I suppose your movie is already done, if not, then finish it.
Follow the instructions very attentively:

- Make a new layer named "Subtitles".
- Add a keyFrame on the frame where you want the player to choose his language.
- Make as many buttons as the number of languages available.
- Give the buttons the following code:

Button one: (Without subtitles)
on(press){
_root.language = 1;
}

Button two: (Language 1)
on(press){
_root.language = 2
}
Button three: (Language 2)
on(press){
_root.language = 3;
}

etc...
- Add a new keyFrame on every frame you want the subtitles to change.
- Choose the way you prefer:

Part IV: First way of making subtitles

Create a new MovieClip on the first frame you want the subtitles to appear (Must have a keyFrame). Then, leave a blank frame on frame 1, a frame with the first subtitles on frame 2, 2nd subtitles on frame 3, etc...
After you're done with that, paste the following code on your movieClip:


onClipEvent(enterFrame){
this.gotoAndStop(_root.language);
}

Pretty simple, eh?
Now create a new movieClip, type your subtitles, and add the same code...

Part V: Second way of making subtitles

This one is a little bit more complicated. Make a dynamic textbox. Go to propeties and set its var to: sub <--- case sensitive. Make it multiline. (See picture below).
Now on every keyFrame you have, paste the following code:
(Change the sentences between the hyphens to whatever you want in the language you want)

_root.onEnterFrame = function(){
if(_root.language == 1){
sub = " ";
}
if(_root.language == 2){
sub = "here you need to type the subtitles in the first language you have";
}
if(_root.language == 3){
sub = "here you need to type the subtitles in the second language you have";
}
if(_root.language == 4){
sub = "here you need to type the subtitles in the 3rd language you have";
}
if(_root.language == 5){
sub = "here you need to type the subtitles in the 4th language you have";
}
//etc...
}
Paste that code on every keyframe you have, typing what you want it to be in every language.

Part VI: Test your movie!
Now you can test your movie, you're done!

:)
Have a nice day! :D


BBS Signature

Response to AS: Subtitles. 2005-10-26 07:09:27


why would you use an onEnterFrame? thats just dumb, also why have the subtitles on every keyframe, you only update the subtitles when you need to change them, and the onEnterFrame? wtf

Response to AS: Subtitles. 2005-10-26 07:10:58


1. What's the problem with onenterframe???

2.You probably didn't read it entirely, I said to make a new keyframe every time you want to change it.


BBS Signature

Response to AS: Subtitles. 2005-10-26 07:57:40


At 10/26/05 07:10 AM, -Toast- wrote: 1. What's the problem with onenterframe???

its not neccesary at all, the variables aernt just suddenly going to reset on the nextframe

2.You probably didn't read it entirely, I said to make a new keyframe every time you want to change it.

oh yeh

Response to AS: Subtitles. 2005-10-26 08:01:23


Hey, thats a really sweet tute Toast! 'Spect from da hood! :|

What the heck.

Yeah, its useful. Wait until Denvish looks around, he'll probably add this to main.


"Actually, the server timed out trying to remove all your posts..."

-TomFulp

Response to AS: Subtitles. 2005-10-26 08:03:05


better yet just make a new layer and change it whenever you want the subtitles to change rather than use AS for no apparent reason :\

sorry but subtitles don't really need any AS


Gamertag: Medieval Turkey.

I also make signatures - PM what you want, and I'll make it.

BBS Signature

Response to AS: Subtitles. 2005-10-26 08:04:28


At 10/26/05 07:57 AM, dELta_Luca wrote:
At 10/26/05 07:10 AM, -Toast- wrote: 1. What's the problem with onenterframe???
its not neccesary at all, the variables aernt just suddenly going to reset on the nextframe

Hmm.. I guess you're right...
Basically, if you dont put a clip event and it's on the timeline, it's like onClipEvent(load)?

2.You probably didn't read it entirely, I said to make a new keyframe every time you want to change it.
oh yeh

oh yey


BBS Signature

Response to AS: Subtitles. 2005-10-26 08:06:40


At 10/26/05 08:01 AM, IWantSomeCookies wrote: Hey, thats a really sweet tute Toast!

Thanks :)

'Spect from da hood! :|

>: |

Yeah, its useful. Wait until Denvish looks around, he'll probably add this to main.

Yeah, probably in the "beginner" section.

At 10/26/05 08:03 AM, lucozadedude wrote: better yet just make a new layer and change it whenever you want the subtitles to change rather than use AS for no apparent reason :\

sorry but subtitles don't really need any AS

No offence, but people can sometimes be really dumb... Did you even read my post?

"WARNING: This tutorial will NOT teach you other languages, if you only speak english and you don't have a translator, this tutorial will be quite useless for you."

It means that it's only necessary if you want MORE than one language...


BBS Signature

Response to AS: Subtitles. 2005-10-26 08:08:54


Or you could have a movie clip masking the subtitles, and script it to go to a blank keyframe when you want them to turn off. That way it's a lot easier to line them up with the movie.


BBS Signature

Response to AS: Subtitles. 2005-10-26 08:13:15


At 10/26/05 08:08 AM, -Paranoia- wrote: Or you could have a movie clip masking the subtitles, and script it to go to a blank keyframe when you want them to turn off. That way it's a lot easier to line them up with the movie.

You still need AS for that..


BBS Signature

Response to AS: Subtitles. 2005-10-26 08:20:10


At 10/26/05 08:13 AM, -Toast- wrote:
At 10/26/05 08:08 AM, -Paranoia- wrote: Or you could have a movie clip masking the subtitles, and script it to go to a blank keyframe when you want them to turn off. That way it's a lot easier to line them up with the movie.
You still need AS for that..

Yeah but you didn't cover it!

Anyway it isn't much AS. Hack, if you put the button inside the movie clip you can even get away without having a target path.


BBS Signature

Response to AS: Subtitles. 2005-10-26 08:42:33


At 10/26/05 08:20 AM, -Paranoia- wrote: Yeah but you didn't cover it!

So what? it does that same thing anyways.

Anyway it isn't much AS.

That's why it's for beginners...


BBS Signature

Response to AS: Subtitles. 2005-10-27 00:43:55


At 10/26/05 07:10 AM, -Toast- wrote: 1. What's the problem with onenterframe???

2.You probably didn't read it entirely, I said to make a new keyframe every time you want to change it.

Don't fight with your master >:(


wat

Response to AS: Subtitles. 2005-10-27 04:51:20


At 10/27/05 12:43 AM, -Thomas- wrote: Don't fight with your master >:(

Lol, don't make angry smilies to your master! >:O


BBS Signature

Response to AS: Subtitles. 2005-10-27 04:55:05


Yay, this is gonna help me a lot!

Now I should finish the movie I want subtitles for :P

anyways: thanks!

Response to AS: Subtitles. 2005-10-27 06:57:57


onEnterFrame kinda eats up cpu cycles

Response to AS: Subtitles. 2005-10-27 07:01:37


*Sigh...*

PART V: Second way of making subtitles

if(_root.language == 1){
sub = " ";
}
if(_root.language == 2){
sub = "here you need to type the subtitles in the first language you have";
}
if(_root.language == 3){
sub = "here you need to type the subtitles in the second language you have";
}
if(_root.language == 4){
sub = "here you need to type the subtitles in the 3rd language you have";
}
if(_root.language == 5){
sub = "here you need to type the subtitles in the 4th language you have";
}
//etc...

Happy? :)


BBS Signature

Response to AS: Subtitles. 2005-11-24 14:31:56


Can't it be easier?
Make a dynamic textbox with the name "subtitles"
and add this script on the frame where you need subtitles:
_root.subtitles="Addyoursubtitleshere"
Of course, if you want multi-language or new unlockable subtitles, this is cool.
All the other ppl were right, i dont like the onEnterFrame function too.
It once added my score with 3 instead of 1.
Nice tutorial.


I'm one of the people who doesn't have text in his signature.

Response to AS: Subtitles. 2005-11-24 14:45:32


At 10/27/05 07:01 AM, -Toast- wrote: *Sigh...*

PART V: Second way of making subtitles

if(_root.language == 1){
sub = " ";
}
if(_root.language == 2){
sub = "here you need to type the subtitles in the first language you have";
}
if(_root.language == 3){
sub = "here you need to type the subtitles in the second language you have";
}
if(_root.language == 4){
sub = "here you need to type the subtitles in the 3rd language you have";
}
if(_root.language == 5){
sub = "here you need to type the subtitles in the 4th language you have";
}
//etc...

Happy? :)

Hmmm, I think it's a bit clumsy (I always make my flashes in three languages, I'm a native bilingual, and putting all button texts and messages in this way would be extremely painful). Better work with arrays:

Array.prototype.subtitle=function(){return this[_root.language];}

sub=["This is an English subtitle","Esto es un subtítulo en castellano","Això és un subtítol en català","C'est un subtitle en français"];

trace(sub.subtitle());

& so on. If you don't like the proto thingie, better then to use a switch(_root.language) instead than a lot of ifthens.

Response to AS: Subtitles. 2006-05-15 11:05:13


Just thought it worth adding here: for Flash 8 users it's worth having a strong glow filter of contrasting colour to your subtitles applied to them. Say if you were using white subtitles, you could have a black glow. This gets around the problem of the subtitles being difficult to see against certain backgrounds, and also looks pretty damn proffesional (Arial ftw!).

If you don't like using filters you could also draw a box behind them to solve the same problem (although this doesn't look as good).


BBS Signature

Response to AS: Subtitles. 2006-06-14 14:32:45


I like off-set drop-shadows.

Just an identical mc copy, darker colour, offset.

For the code - an array definitely seems the way to go. But this is simpler for newbs to type and understand, I suppose...

Response to AS: Subtitles. 2007-12-20 20:23:52


Question!:
Does this still work if the language selection buttons are on another scene than the subtitles themselves?

I think I've done everything as it is here but the subtitles still dont appear. And I can't think of a reason.

I chose the second way, because my file is already too big and laggy for adding any more movieclips ...

So, those anyone has the slightliest idea of why they still don't appear? Is there any common mistake while using this way? Is there a better non-many-symbol-using method that an AS noob can understand (i didnt understand that array one someoen mentioned) ?

-thanks, sorry for bumping an old thread..

Response to AS: Subtitles. 2007-12-21 15:30:36


Just had a read of this after posting in PinkSkull's other thread on the subject and thought I'd add my 2 cents.

Apparently, changing the contents of text boxes is a slow operation and should only be done when absolutely necessary. In a game, for example you would only update the score diaply when the score changes. Just another reason not to use that enterFrame method, because it causes the text box to update every frame.

Response to AS: Subtitles. 2008-05-06 20:02:54


WOW!
thanks pal, luckily i know 2 languages
los voy a usar ahora mismo!
=)