Be a Supporter!

AS: Subtitles.

  • 4,466 Views
  • 23 Replies
New Topic Respond to this Topic
Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
AS: Subtitles. 2005-10-26 07:01:25 Reply

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
dELtaluca
dELtaluca
  • Member since: Apr. 16, 2004
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to AS: Subtitles. 2005-10-26 07:09:27 Reply

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


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature
Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to AS: Subtitles. 2005-10-26 07:10:58 Reply

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
dELtaluca
dELtaluca
  • Member since: Apr. 16, 2004
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to AS: Subtitles. 2005-10-26 07:57:40 Reply

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


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature
IWantSomeCookies
IWantSomeCookies
  • Member since: Aug. 20, 2004
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to AS: Subtitles. 2005-10-26 08:01:23 Reply

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

Lucozadedude
Lucozadedude
  • Member since: Jul. 28, 2005
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to AS: Subtitles. 2005-10-26 08:03:05 Reply

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
Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to AS: Subtitles. 2005-10-26 08:04:28 Reply

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
Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to AS: Subtitles. 2005-10-26 08:06:40 Reply

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
Paranoia
Paranoia
  • Member since: Apr. 22, 2005
  • Offline.
Forum Stats
Member
Level 35
Game Developer
Response to AS: Subtitles. 2005-10-26 08:08:54 Reply

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
Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to AS: Subtitles. 2005-10-26 08:13:15 Reply

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
Paranoia
Paranoia
  • Member since: Apr. 22, 2005
  • Offline.
Forum Stats
Member
Level 35
Game Developer
Response to AS: Subtitles. 2005-10-26 08:20:10 Reply

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
Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to AS: Subtitles. 2005-10-26 08:42:33 Reply

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
Thomas
Thomas
  • Member since: Feb. 14, 2005
  • Offline.
Forum Stats
Member
Level 13
Musician
Response to AS: Subtitles. 2005-10-27 00:43:55 Reply

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
a compessor wil raise the volume while lowering the db - chronamut

Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to AS: Subtitles. 2005-10-27 04:51:20 Reply

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
Jovatov
Jovatov
  • Member since: Apr. 26, 2004
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Response to AS: Subtitles. 2005-10-27 04:55:05 Reply

Yay, this is gonna help me a lot!

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

anyways: thanks!

krazed428657
krazed428657
  • Member since: Jan. 19, 2004
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to AS: Subtitles. 2005-10-27 06:57:57 Reply

onEnterFrame kinda eats up cpu cycles

Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to AS: Subtitles. 2005-10-27 07:01:37 Reply

*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
Mr-Dark
Mr-Dark
  • Member since: Dec. 7, 2004
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to AS: Subtitles. 2005-11-24 14:31:56 Reply

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.

ZYX3D
ZYX3D
  • Member since: Jul. 31, 2004
  • Offline.
Forum Stats
Member
Level 21
Blank Slate
Response to AS: Subtitles. 2005-11-24 14:45:32 Reply

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.

Paranoia
Paranoia
  • Member since: Apr. 22, 2005
  • Offline.
Forum Stats
Member
Level 35
Game Developer
Response to AS: Subtitles. 2006-05-15 11:05:13 Reply

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
Bezman
Bezman
  • Member since: Aug. 16, 2001
  • Offline.
Forum Stats
Member
Level 29
Melancholy
Response to AS: Subtitles. 2006-06-14 14:32:45 Reply

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

PinkSkull
PinkSkull
  • Member since: Jan. 6, 2006
  • Offline.
Forum Stats
Member
Level 25
Animator
Response to AS: Subtitles. 2007-12-20 20:23:52 Reply

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

under-siege
under-siege
  • Member since: May. 11, 2007
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
Response to AS: Subtitles. 2007-12-21 15:30:36 Reply

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.

Juanchi
Juanchi
  • Member since: Feb. 6, 2006
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to AS: Subtitles. 2008-05-06 20:02:54 Reply

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