|
|
||||||||||
| Ultrashock Tutorials > Flash 8 > Dynamic OOP Music Player | ||||||||||
|
||||||||||
|
|
Dynamic OOP Music Player |
|
||||||||
4. The Library Class and ConclusionThis class is used to fix object scope using the apply function. Its functionality is the same as Macromedia’s Delegate class except it enables you to pass parameters to the callback method. For example, say your trying to access a property called “score” inside an onEnterFrame event in a class, without either delegating or storing a local variable to path with you wouldn’t be able to access the property. Valid - Delegate: private function phone():Void Valid – Local Property: private function phone():Void Invalid private function phone():Void For these reasons this class has been made to fix the problem. class Library return function () Save it with the MusicPlayer class as Library.as. Conclusion That’s it you should now have a working music player. You’ve done, or maybe just read a lot in this article, either way thank you for taking the time, and I hope it has helped you to better understand OOP and maybe even made a nice music player for your site. View Demo - Download Completed Sources All used music in this demo comes from Ultrashock Audio Essentials btw.
Additions Near the beginning of this article I mentioned how easy it would be to make the player dynamic by populating the tracks object via XML. I wanted to elaborate on this topic as I’m sure many people would like to be able to easily add XML support. Inside the Flash file I changed the code to the following: function convertXML():Object var xml = new XML(); Resave the Flash file (File > Save). Now open your favorite text editor and paste the following: <?xml version="1.0" encoding="utf-8"?> Save the file as tracks.xml in the main folder ( musicplayer/tracks.xml ). Don't forget to edit the data inside this file to accommodate your tracks before testing out the player. I tried to explain everything in the comments, but if you are still having trouble understanding what exactly is going on here, read my XML in Flash article.
|
||||||||||
©2006 Ultrashock.com - All rights reserved |