Flash 3: MP3 Player

Posted by PH on April 15, 2007
Uncategorized

Return visitors may note the appearance of an MP3 player at the bottom of the right-hand column. So, firstly: go put some music on! Mmmmm….

The impetus to make one of these now came out of my teaching, but it was one of those things I ‘d been promising myself to do for ages. Anyway, we’d been talking in class about interface objects that behaved in the same way that ‘real’ objects do—i.e. those that seem to obey the laws of physics—and I’d mentioned Joshua Davis‘ slider that you can ‘throw’ and that seems to ‘bounce off’ the end of its gutter. I went back and got the code walk-through from Davis’ excellent Flash To The Core book, and the basic interaction on my player ended up a version of that hacked to work vertically instead of horizontally. The rest of the code is pretty generic stuff…

The .fla (104kB) in MX2004 format is here. All Davis’ code has been updated for Actionscript 2.0 compliance. If you want to use it, all you have to do is:

  • Number your mp3s sequentially by number (i.e. 01.mp3, 02.mp3, etc.). This means you don’t have to keep updating the button codes.
  • Put them on your web space, ideally in a folder called “mp3s”.
  • Put the relevant code pointing to these files into the buttons. All code is in the ‘Actions’ layer. Yes, it’s commented.
  • Type the artist and song titles into the ‘content_mc’ movie clip.
  • Publish.

Amazingly, the whole thing weighs in at a mere 12kB when embedded in a page. Sweet!

Tags: , ,

1 Comment to Flash 3: MP3 Player

  • Good job…
    If you can’t be bothered or it’s impossible for you to name your mp3’s sequentially (for example if all the songs are already saved on a server, or there’s too many to be worth the effort renaming) a method I used was to have Flash read an easily editable text file instead. It’s no harder to do and has the advantage of being more dynamic… the text file could also be generated by some php script for instance meaning that users could link up their uploaded songs to the system.
    Just a thought, enjoying the tunes (for the most part…)!

Leave a Reply

Your email address will not be published. Required fields are marked *