Forum Topic: AS: Subtitles.

(3,420 views • 23 replies)

This topic is 1 page long.

<< < > >>
None

Toast

Reply To Post Reply & Quote

Posted at: 10/26/05 07:01 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

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

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

dELtaluca

Reply To Post Reply & Quote

Posted at: 10/26/05 07:09 AM

dELtaluca LIGHT LEVEL 20

Sign-Up: 04/16/04

Posts: 5,117

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

My social worker says im special!

BBS Signature

None

Toast

Reply To Post Reply & Quote

Posted at: 10/26/05 07:10 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

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.

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

dELtaluca

Reply To Post Reply & Quote

Posted at: 10/26/05 07:57 AM

dELtaluca LIGHT LEVEL 20

Sign-Up: 04/16/04

Posts: 5,117

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

My social worker says im special!

BBS Signature

None

IWantSomeCookies

Reply To Post Reply & Quote

Posted at: 10/26/05 08:01 AM

IWantSomeCookies LIGHT LEVEL 13

Sign-Up: 08/20/04

Posts: 3,291

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


None

Lucozadedude

Reply To Post Reply & Quote

Posted at: 10/26/05 08:03 AM

Lucozadedude FAB LEVEL 11

Sign-Up: 07/28/05

Posts: 3,940

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

None

Toast

Reply To Post Reply & Quote

Posted at: 10/26/05 08:04 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

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

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Toast

Reply To Post Reply & Quote

Posted at: 10/26/05 08:06 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

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...

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Paranoia

Reply To Post Reply & Quote

Posted at: 10/26/05 08:08 AM

Paranoia DARK LEVEL 31

Sign-Up: 04/22/05

Posts: 9,119

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.

A rate of change in sanity with respect to time.

BBS Signature

None

Toast

Reply To Post Reply & Quote

Posted at: 10/26/05 08:13 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

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..

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Paranoia

Reply To Post Reply & Quote

Posted at: 10/26/05 08:20 AM

Paranoia DARK LEVEL 31

Sign-Up: 04/22/05

Posts: 9,119

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.

A rate of change in sanity with respect to time.

BBS Signature

None

Toast

Reply To Post Reply & Quote

Posted at: 10/26/05 08:42 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

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...

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Thomas

Reply To Post Reply & Quote

Posted at: 10/27/05 12:43 AM

Thomas LIGHT LEVEL 13

Sign-Up: 02/14/05

Posts: 2,429

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


None

Toast

Reply To Post Reply & Quote

Posted at: 10/27/05 04:51 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

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

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Jovatov

Reply To Post Reply & Quote

Posted at: 10/27/05 04:55 AM

Jovatov LIGHT LEVEL 16

Sign-Up: 04/26/04

Posts: 1,879

Yay, this is gonna help me a lot!

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

anyways: thanks!


None

krazed428657

Reply To Post Reply & Quote

Posted at: 10/27/05 06:57 AM

krazed428657 NEUTRAL LEVEL 07

Sign-Up: 01/19/04

Posts: 343

onEnterFrame kinda eats up cpu cycles


None

Toast

Reply To Post Reply & Quote

Posted at: 10/27/05 07:01 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

*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? :)

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Mr-Dark

Reply To Post Reply & Quote

Posted at: 11/24/05 02:31 PM

Mr-Dark LIGHT LEVEL 06

Sign-Up: 12/07/04

Posts: 107

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.


None

ZYX3D

Reply To Post Reply & Quote

Posted at: 11/24/05 02:45 PM

ZYX3D DARK LEVEL 21

Sign-Up: 07/31/04

Posts: 437

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.


None

Paranoia

Reply To Post Reply & Quote

Posted at: 5/15/06 11:05 AM

Paranoia DARK LEVEL 31

Sign-Up: 04/22/05

Posts: 9,119

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).

A rate of change in sanity with respect to time.

BBS Signature

None

Bezman

Reply To Post Reply & Quote

Posted at: 6/14/06 02:32 PM

Bezman FAB LEVEL 29

Sign-Up: 08/16/01

Posts: 2,644

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...


None

PinkSkull

Reply To Post Reply & Quote

Posted at: 12/20/07 08:23 PM

PinkSkull LIGHT LEVEL 22

Sign-Up: 01/06/06

Posts: 1,441

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..

La vida no tiene sentido xD

BBS Signature

None

under-siege

Reply To Post Reply & Quote

Posted at: 12/21/07 03:30 PM

under-siege DARK LEVEL 03

Sign-Up: 05/11/07

Posts: 550

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.


Elated

Juanchi

Reply To Post Reply & Quote

Posted at: 5/6/08 08:02 PM

Juanchi LIGHT LEVEL 10

Sign-Up: 02/06/06

Posts: 35


All times are Eastern Standard Time (GMT -5) | Current Time: 11:38 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!