In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: Simple LRC player

Simple LRC player. Can easily go out of sync online.
@author makc
@license WTFPLv2
Get Adobe Flash player
by greko 08 Aug 2010
// forked from makc3d's Simple LRC player
package  {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.ProgressEvent;
    import flash.media.Sound;
    import flash.net.URLRequest;
    import flash.text.TextField;
    import flash.utils.setTimeout;
    
    /**
    * Simple LRC player. Can easily go out of sync online.
    * @author makc
    * @license WTFPLv2
    */
    public class LRCPlayer extends Sprite {
        private var tf:TextField;
        
        public function LRCPlayer () {
            var s:Sound = new Sound;
            s.addEventListener (ProgressEvent.PROGRESS, start);
            s.load (new URLRequest ("http://spbdio.com/playlist/track2.mp3"));
            s.play ();
        }

        private function start (e:ProgressEvent):void {
            if (e.bytesLoaded < 1) return;
            e.target.removeEventListener (ProgressEvent.PROGRESS, start);

            tf = new TextField;
            tf.textColor = 255 * 256;
            tf.autoSize = "left";
            addChild (tf);

            var lines:Array = lrc.toString().split("\n");
            for each (var line:String in lines) {
                var a:Array = line.match (/^\[(\d+)\:([\d\.]+)\](.*)$/);
                if (a != null) {
                    trace (a)
                    setTimeout (function (msg:String):void { tf.text = msg; },
                        parseInt (a[1]) * 60 * 1000 + parseFloat (a[2]) * 1000,
                        a [3]);
                }
            }
        }
        
        private var lrc:XML = <lrc>[ti:All Star]
[ar:Smash Mouth]
[al:All Star Smash Hits]
[by:Someone]
[00:00.30]Somebody once told me the world is gonna roll me
[00:05.50]I ain't the sharpest tool in the shed
[00:09.85]She was looking kind of dumb with her finger and her thumb
[00:14.05]In the shape of an "L" on her forehead
[00:17.75]
[00:18.90]Well the years start coming and they don't stop coming
[00:21.85]Back to the rule and I hit the ground running
[00:24.20]Didn't make sense not to live for fun
[00:26.50]Your brain gets smart but your head gets dumb
[00:28.20]
[00:28.80]So much to do so much to see
[00:30.50]So what's wrong with taking the back streets
[00:33.40]You'll never know if you don't go
[00:35.80]You'll never shine if you don't glow
[00:37.10]
[00:38.10]Hey now you're an All Star get your game on, go play
[00:42.50]Hey now you're a Rock Star get the show on, get paid
[00:47.05]And all that glitters is gold
[00:50.80]Only shooting stars break the mold
[00:55.00]
[00:56.20]It's a cool place and they say it gets colder
[00:58.70]You're bundled up now but wait 'til you get older
[01:00.85]But the meteor men beg to differ
[01:02.85]Judging by the hole in the satellite picture
[01:04.35]
[01:05.05]The ice we skate is getting pretty thin
[01:07.40]The waters getting warm so you might as well swim
[01:09.60]My world's on fire how about yours
[01:12.05]That's the way I like it and I never get bored
[01:13.90]
[01:15.10]Hey now you're an All Star get your game on, go play
[01:19.50]Hey now you're a Rock Star get the show on, get paid
[01:23.85]And all that glitters is gold
[01:27.70]Only shooting stars break the mold
[01:32.10]
[01:48.50]
[01:51.95]Hey now you're an All Star get your game on, go play
[01:56.50]Hey now you're a Rock Star get the show on, get paid
[02:00.85]And all that glitters is gold
[02:04.50]Only shooting stars
[02:06.80]
[02:07.50]Somebody once asked could I spare some change for gas
[02:11.75]I need to get myself away from this place
[02:16.70]I said yep what a concept
[02:18.90]I could use a little fuel myself
[02:21.05]And we could all use a little change
[02:25.20]
[02:25.80]Well the years start coming and they don't stop coming
[02:28.85]Back to the rule and I hit the ground running
[02:31.15]Didn't make sense not to live for fun
[02:33.35]Your brain gets smart but your head gets dumb
[02:34.95]
[02:35.65]So much to do so much to see
[02:37.50]So what's wrong with taking the back streets
[02:40.20]You'll never know if you don't go
[02:42.50]You'll never shine if you don't glow
[02:43.90]
[02:44.90]Hey now you're an All Star get your game on, go play
[02:49.50]Hey now you're a Rock Star get the show on, get paid
[02:53.95]And all that glitters is gold
[02:57.65]Only shooting stars break the mold
[03:03.30]And all that glitters is gold
[03:06.90]Only shooting stars break the mold
[03:12.00]
</lrc>;
    }
}