AS3 SRT Subtitle in SWF

Hi all,
I've been looking at some tutorials in how to add SRT subtitles in flash. I found this grea article in base42 but i'm not finding a way to make it work can anyone give me a hand in how this works?
PLS HELP!!!
Let's say I have 4 files
movie.fla (movie.swf)
// I need to make the subtitle SRT show on the textBox_txt during my animation (timeline)
textBox_txt.text = subtitle.srt
subtitle.srt
1
00:00:20,000 --> 00:00:24,400
In connection with a dramatic increase
in crime in certain neighbourhoods,
2
00:00:24,600 --> 00:00:27,800
the government is implementing a new policy...
SubtitleParser.as
package nl.inlet42.data.subtitles {
      *     @author Jankees.van.Woezik
     public class SubtitleParser {
          public static function parseSRT(data : String) : Array {
               var result : Array = new Array();
               var lines : Array;
               var translation : SubTitleData;
               var blocks : Array = data.split(/^[0-9]+$/gm);
               for each (var block : String in blocks) {
                    translation = new SubTitleData();
                    lines = block.split('\n');
                    for each (var line : String in lines) {
                         //all lines in a translation block
                         if(trim(line) != "") {
                              if(line.match("-->")) {
                                   //timecodes line
                                   var timecodes : Array = line.split(/[ ]+-->[ ]+/gm);
                                   if(timecodes.length != 2) {
                                        trace("Translation error, something wrong with the start or end time");                                   
                                   } else {
                                        translation.start = stringToSeconds(timecodes[0]);
                                        translation.end = stringToSeconds(timecodes[1]);
                                        translation.duration = translation.end - translation.start;
                                        if(translation.duration < 0) {
                                             trace("Translation error, something wrong with the start or end time");                                   
                              } else {
                                   //translation line
                                   if(translation.text.length != 0) line = "\n" + trim(line);
                                   translation.text += line;
                    result.push(translation);
               return result;
          public static function trim(p_string : String) : String {
               if (p_string == null) {
                    return '';
               return p_string.replace(/^\s+|\s+$/g, '');
           * Convert a string to seconds, with these formats supported:
           * 00:03:00.1 / 03:00.1 / 180.1s / 3.2m / 3.2h / 00:01:53,800
           * Special thanks to Thijs Broerse of Media Monks!
          public static function stringToSeconds(string : String) : Number {
               var arr : Array = string.split(':');
               var sec : Number = 0;
               if (string.substr(-1) == 's') {
                    sec = Number(string.substr(0, string.length - 1));
               }else if (string.substr(-1) == 'm') {
                    sec = Number(string.substr(0, string.length - 1)) * 60;
               }else if(string.substr(-1) == 'h') {
                    sec = Number(string.substr(0, string.length - 1)) * 3600;
               }else if(arr.length > 1) {
                    if(arr[2] && String(arr[2]).indexOf(',') != -1) arr[2] = String(arr[2]).replace(/\,/, ".");
                    sec = Number(arr[arr.length - 1]);
                    sec += Number(arr[arr.length - 2]) * 60;
                    if(arr.length == 3) {
                         sec += Number(arr[arr.length - 3]) * 3600;
               } else {
                    sec = Number(string);
               return sec;
SubTitleData.as
package nl.inlet42.data.subtitles {
     public class SubTitleData {
          public var text : String;
          public var start : Number;
          public var duration : Number;
          public var end : Number;
          public function SubTitleData(inText : String = "",inStart : Number = 0,inDuration : Number = 0,inEnd : Number = 0) {
               text = inText;
               start = inStart;
               duration = inDuration;
               end = inEnd;
          public function toString() : void {
               trace("nl.inlet42.data.subtitles.SubTitleData");
Thansk a lot!!!

Since you mention AS3 in the subject line, wouldn't it be more logical to ask the question in the AS3 forum?

Similar Messages

  • Avi+SRT subtitles on Apple TV ...and more.

    Hi,
    3 questions (hope it´s not too much):
    1.
    I would like to read Avi+SRT subtitles on Apple TV without further convertion.
    Does anybody use this or other solution with good results?
    <Edited by Moderator>
    2.
    Is it true that current Apple Tv do not support Full HD video 1920x1080?
    3.
    Will I be able to play Blu-ray films from my computer BR player with Apple TV?
    Thanks very much.
    Regards
    L.

    Hi,
    thanks for the quick replies.
    So sorry if I asked for something that it´s not "proper" for this forum, but they say:
    "The aTV Flash is a software upgrade that will greatly enhance the functionality of the Apple TV. The software is simple to install, and requires no modification or tricky coding. The software can be easily removed at any time, and it will NOT void the warranty."

  • How to create SRT subtitle files?

    Hi. I created some movies in iMovie and published them to iTunes, where they appear as "QuickTime movie files". I want to add subtitles to these movies, and to some m4v movies. I know how to use iSubtitle to add subtitles to a movie, but that is when I already have an SRT subtitles file. I do not know how to create an SRT subtitle file from scratch. Does anyone know what product / editor to use to create SRT files? Thank you

    I found out the Max TextEdit software can be used for this ...

  • Adding SRT subtitles to FCPX or FCP7 timelines

    I made an App called Final SRT for importing SRT subtitle to Final Cut Pro X or Final Cut Pro 7. Many people had been asking for this for a long time. You can buy it from Mac App Store.
    I may receive some form of compensation, financial or otherwise, from my recommendation or link.
    <Edited by Host>

    Actually, I've been playing around with the new Closed Caption Importer component
    http://developer.apple.com/samplecode/ClosedCaptionImporter/index.html
    I like the look of it and it just needs to be fleshed out to be more user friendly for the creation of captions, but it's following a standard that allows the captions to be inside the movie file. (Some of the tools I've found convert .scc to .srt.. with QuickTime able to read the .scc, it should make it easier)
    Message was edited by: Kyn Drake

  • How can I convert video with srt subtitles?

    If I have an avi plus an .srt subtitles file, how can I convert this to play on the iPad?
    If, on my iMac, I use Quicktime, I can save the avi as .mov with hard subs.  But when I convert this .mov to mp4, the subtitles disappear.

    Why go to all the trouble of converting? Why not just download an app that can play .avi files with subtitle support?

  • Multi-line .srt subtitle support?

    I've got a foreign language film .m4v with soft-embedded .srt subtitles. (I used Subler to add the .srt track) In subtitle editors like Jubler, the subtitles are spanned across two lines. These display as two lines of dialogue in Quicktime in 10.6.2, but on my AppleTV (v 3.0.2) they display as one line, so the text ends up getting truncated with "..." on the end.
    So for example:
    In QT:
    A brave man sheds blood
    before he sheds tears.
    In ATV:
    A brave man sheds blood before he sheds ...
    Am I using the wrong character to do a "newline"?

    Anyone? Nobody else has used multi-line subtitle tracks?
    Should I be submitting this to Apple Bugs?

  • Convert .srt subtitles

    How do I convert a .srt subtitle file to import into DVDSP4? I'm new to using subtitles and have no idea how they work. All I know is I have the movie imported fine, but I was given subtitles as a .srt file. What do I do? Any help is greatly appreciated.
    Thanks all

    After some research, I found a nice program that will import the srt file (TitleLAB). I then export it for DVD Studio Pro. However, when I go to import it to my project, DVD SP says
    "No corresponding subtitles found.
    The video asset timecode may not correspond with the timecode specified for the subtitles in the import file or the file is invalid."
    This doesn't make sense to me. What can I do, or what am I doing wrong?

  • No SRT subtitles via DLNA on Samsung ue48js9000 with my book live 4TB

    Hi,I just bought the new Samsung ue48js9000 uhd and cannot play SRT subtitles via DLNA / Network (tried cable and Wifi) with WD my book live 4TB. Embebed subtitles in MKV play ok. SRT subtitles play ok if connected via USB drive to OCB. With other TV's at home SRT subtitles play fine via DLNA / Network (Samsung F7000 and D6500). FW Versions are (latest I can find by 30.JUL.2015):Samsung JS900: 1214WD My Cloud: v04.01.04-422DLNA Media Server (Twonky): 7.2.9_7.5.0-43  Tried to rebuid database and configurations on the twonky access port :9000 with different settings for the TV with no differente results (Generic Media Receiver, Samsung TV, ...) - note that it defaults do "Samsung Smart TV" which I beleive to be ok. Any help would be appreciated. Best regards, 
    Joao

    JMora wrote:
    The srt names are the same as the MP4 files and display well with other older Samsung sets (2013 f7000 and 2011 d6500) via dlna/network. Only doesn't have subtitles with this new uhd TV js9000 via dlna/network.If the older Samsung sets (2013 f7000 and 2011 d6500) properly display SRT subtitle files via DLNA from the WD My Cloud, that would indicate a problem with your new Samsung JS9000 TV and its built in DLNA client software/application. If this is the case then you should contact Samsung to see if there is a firmware or app update for your TV. Otherwise about the only other suggestion I have at the moment, if the SRT files display properly on other devices that access the WD My Cloud, is to check the Twonky Server settings on the WD My Cloud to see how the Twonky server is treating your TV in the "Media Receiver Type" field under Sharing -> Media Receiver. If the value for "Media Receiver Type" is something other than "Samsung TV" or "Samsung Smart TV" then you may have to change the value and test to see if it fixes the issue. For more information on how to access the Twonky Server on the WD My Cloud see the following WD Support link: How to access the Twonky Media Server on a WD NAS

  • Tip: (Cyrillic) .srt subtitles with QuickTime Player!

    Thanks to the great team that is behind the Perian project we can now watch XviD, DIvX, whatever codec video content complete with .srt subtitle tracks inside QuickTime Player, Front Row and everywhere else you can play quicktime files. The function is not part of the Perian version available for download just yet, you have to compile it yourself using Apple's Xcode tools and the source code available from perian.org via subversion, but it is really, really easy! I've posted detailed instructions on my blog at http://etosx.blogspot.com for those who have not played with Xcode.
    MBP 2.16 2GB RAM, 120GB HDD   Mac OS X (10.4.9)  

    n/a

  • Disable SRT subtitles in Quicktime

    Hello,
    I have been looking for an answer for quite some time now, so I'll post my problem here and hope for someone to find a solution.
    When I play an AVI movie file with QuickTime Player, it automatically displays the SRT subtitles if located in the same folder. But when I try to disable those subs (via the menu bar), the menu supposed to display "1-Off, 2-English, 3-Spanish..." is gray and "Off" is selected. But the subs are played!
    Example:
    2 Files in Folder "My movies" -> "my_movie1.avi" and "my_movie1.srt"
    Note: removing/renaming the SRT file is NOT an option.

    If you look in the Perian control panel, you will see a tick box called 'load external subtitles'. This referrs to loading .srt files. With this option unticked (turned off) it will no longer always show subtitles.

  • Srt subtitles on Apple TV

    Hi, I have this home made movie AVI+SRT subtitle file that I want to watch on my Apple TV. Can someone explain me the process to do this without "paste" the subtitles by using submerge? is it posible? I know that Apple Tv has a subtitle option on settings for Rentals movie that actually has CC but how this works in a home made movie?
    thanks!

    Hi tmartine thanks for your replay, but Quicktime is not the problem, actually I can perfectly watch the movie with the srt subtitles in Quicktime by using perian. The thing is How to do the same in the Apple Tv without having to paste the subtitles in the film using submerge.
    thanks anyway
    Message was edited by: jark

  • Add .srt subtitles

    I'd like to add .srt subtitles to a .avi movie. Anyone know how to convert .srt to a Premiere Elements compatible format? .. or would Encore be a better way to go?

    Steve,
    Encore can work with true Sub-Titles (and also Closed Caption, which is similar, though different), and can use most common Sub-Title text formats.
    For specific Encore questions, including Sub-Titles, the Encore Forum is a great place.
    Good luck,
    Hunt

  • Load external swf thats AS3 in a AS2 swf

    i have a website made in actionscript 2, and now i need some
    functions from actionscript3 that actionscript 2 doesnt have, so im
    trying to load a external actionscript 3 swf in to a actionscript 2
    swf, is this possible?
    im using _root.mc.loadMovie("ms.swf");
    cuz it doesnt seem to work

    ah ok thanks
    have any idea how to load text into swf in AS2.0 without
    having a tag like text= ... because as far as i know only AS3's
    URLLoader can do it.

  • AS3: Could we convert .swf into .flv and .flv into .swf

    I'm searching for a program that can take an .flv and convert it to an AS3 .swf file. Is it possible in as3, Does anybody have any ideas?
    I am not talking about any third party converter software.
    Thanks,

    Hi swati61,
    I'm not sure why do you want to play an swf file in flv player. Will you post it on your website?
    If yes, here is a solution:
    http://www.swfkits.com/swf-to-flv-converter/
    If you want to convert flv to swf, you can check this
    www.flash-video-mx.com/video_to_flash_web/

  • AS3 issue embedding AS2 .swf files

    Hi there,
    I'm attempting to create a menu navigation system with Flash/AS3 that opens up a series of older AS2 activities.
    At the moment I'm testing it with two buttons/two activities.
    The problem I'm having is that when I'm testing the navigation, the first button clicked will open its respective activity correctly, which can then be shut down using the original activity's exit button, and return to the two buttons on my AS3 menu. However, if I then select the other activity from the same screen, it won't load. I'm able to click the original activity again, and have it open, but not the new one.
    If I test the main flash navigation file again and click the other button first (that wasn't working), the other activity opens fine, and can be closed down. However the first button now won't open the activity. So both the buttons work (if they're the first ones clicked), but from then on, only the first button clicked works.
    In the debug panel, it looks as if the AS2 .swf files that I'm attempting to embed are themselves embedding a wrapper.swf file (with navigation buttons) as well as another sub set of shared .swf files for their own operation. Might it possible that these sub swf files aren't being unloaded properly when I switch between the main AS2 movies from my menu system?
    Is there a way to clear/unload everything that's been loaded (even resources loaded by the external files themselves - like a hard reset) between button presses?
    I have no access to the original AS2 code as this was done by another team years back.
    I'd be really grateful for any help or advice that anyone might be able to give.
    Thanks

    Just looking at the debugging panel, this is what I see when I try and run the program:
    Attempting to launch and connect to Player using URL /*****/*****/****.swf
    [SWF] Volumes:Data:Documents:*****:****:****:*****.swf - 876582 bytes after decompression
    [SWF] Volumes:Data:Documents:*****:****:****:*****:F11_pr_qu_3:quiz.swf - 176016 bytes after decompression
    LocateFolders.enginesFolder(file:///*****/****/****/*****/F11_pr_qu_3/quiz.swf)
    [SWF] Volumes:Data:Documents:*****:****:****:*****:F11_pr_qu_3:wrapper.swf - 481279 bytes after decompression
    ### Latest wrapper ###
    etc etc...
    Then follows a whole set of loading instructions and trace instructions put in the as2 swf which show XML files being loaded and the program launching. These must have been put in place by the previous programmer.
    When I click the exit button on the 'embedded' swf, the debugging panel shows things shutting down:
    ActivityToolbar clickQuit()
    Wrapper quitActivity()
    EndGame clear(false)
    Now when I click the second button, I should see a similar set of launching greetings etc. instead it bottles out at the following:
    [SWF] Volumes:Data:Documents:*****:****:****:*****:F11_wb_fc_1:flashcards.swf - 94720 bytes after decompression
    LocateFolders.enginesFolder(file:///file:///*****/****/****/*****/F11_wb_fc_1/flashcards.s wf)
    And there it stops.
    If I restarted the program and pressed the second button first, it would show the flashcards.swf activity loading correctly, but would then refuse to load the first activity when I clicked on the button.

Maybe you are looking for