Flash MX MP3 player version 2, Pg.2
source: http://www.thegoldenmean.com
If you got to this page directly from a search engine or other link, be advised that the tutorial you are currently reading extends an earlier article which you can (and need to) read here
2 — Modify the .fla
As stated on the previous page, this tutorial doesn’t do very much to the Flash movie as we left it in part one. We have to modify the name of the external file it loads to get all its information, and we have to correct one little oversight I made initially.
load a new file
Open the .fla from part one of this series in the Flash editing environment. In the layer that we labled “Logic”, locate the line that loads the external XML file and make the following slight modification:
//Finally! Load the XML document. songList_xml.load("songList.xml.php");
It’s that little extension “.php” that will make all the difference! We’ll see why on page three.
Yes, I could have named the file simply “songList.php”, but I like the little indication that this behaves as though it is an XML file. You will see what I mean by that presently.
display vs title
I mentioned we had to change one other thing because I wasn’t thinking of the future in part one. When I wrote part one, there wasn’t a part two in my mind! I chose the variable name “display” because it was logical: that was the bit of data you would see in the ListBox. It would be displayed.
Ahhh, but then came the possibility of displaying a great deal more information if we wanted to. And then “display” made a lot less sense. Had I been thinking forward, I would have called the title data what it was: title, because then we could display that as well as anything else we wanted to, including album, artist, track number… You see what I mean? So let this be a lesson to you: think carefully about where your project might wind up before you settle on variable names!
Fortunately this isn’t a hard problem to rectify, but you can see how it could easily have been much worse. The “title” variable is located in one function: createResourceList(). Find that in the “Functions” layer of your .fla and modify it substituting “title” everywhere it had previousy contained “display”, like so:
function createResourceList(resource_array) { var listData = new DataProviderClass(); var resourceCount = resource_array.length; var resource, title, url; for (var i=0, i<resourceCount; i++) { resource = resource_array[i]; //add a consecutive number in front of each title title = i+1+". "+resource.attributes.title; url = resource.attributes.url; listData.addItems ({lable:title, data:url}); } return listData; };
that’s all for now folks…
Well that wasn’t so bad, was it? Now our little movie is all ready for what’s to come. Compile it to a .swf (ignoring the message that it can’t load the file) and publish to generate the html.
Let’s move on to the central feature of this tutorial: PHP coding.
- page one - the introduction
- page three introduces the PHP code
- page four adds some cosmetic embellishments to the Flash movie
--top--