PDA

View Full Version : HTML or Javascript link passing to XML and Flash MP3 player


lknmj
09-11-2009, 01:19 AM
I am not a flash developer, but would like to know how to implement this on my website.

I have a flash MP3 player that reads XML code and plays MP3's at whatever specific location i place in the XML file. However, I placed the MP3 player in the header of my page. I have some HTML links that are the listed separately as the songs that should be played in the player.

1. Song 1
2. Song 2

Etc.. I want to be able to click on one of these links and it loads that song into the flash player at the top of the page. So if I have a list of songs on a page in HTML. I want to be able to click on that link and it loads and plays that song. And so on. How can this be done? Can it?

tadster
09-12-2009, 06:03 AM
yes,

The ExternalInterface Class is what you'll be needing:

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html

you can add a callback from the flash player so that javascript (on a link) in your html can call a function inside the flash player.

inside your actionscript:

if (ExternalInterface.available) {
ExternalInterface.addCallback("songChange", doSongChange);
}

private function doSongChange(toThisSong):void {
//change the song toThisSong
//whatever that entales
}



in your html/javascript (generaly)

<a href="javascript:changeTo('song1');">Song 1</a>

<script type="text/javascript">
function changeTo(thisSong)
{
document.getElementById('myFlashId').songChange(th isSong);
}
</script>



hope this helps

lknmj
09-13-2009, 01:02 AM
Thanks for your help. I will try it out and see what happens :)

gramsmith
09-21-2009, 10:57 AM
Nice information, thanks for sharing with us.