Playing a Sound from JavaScript in the Apollo Beta
source link: http://www.mikechambers.com/blog/2007/06/06/playing-a-sound-from-javascript-in-the-apollo-beta/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Playing a Sound from JavaScript in the Apollo Beta
Wednesday, June 6, 2007
I just finished up a book I have been working on (along with Kevin Hoyt and Danny Dura) that covers using JavaScript and HTML to build Apollo applications. In celebration of finally writing my last example, I wanted to post it here.
Here is a simple example that shows how to use Flash Player and ActionScript APIs directly from JavaScript to play a sound in the upcoming Apollo beta.
<html>
<head>
<script src="ApolloAliases.js" />
<script type="text/javascript">
function playSound()
{
var soundPath = new apollo.URLRequest("app-resource:/sound.mp3");
var s = new apollo.Sound();
s.load(soundPath);
s.play();
}
</script>
</head>
<body>
<input type="button" value="Play" onClick="playSound()">
</body>
</html>
It should be pretty self explanatory, and is a good example of how easy it is to use Flash and ActionScript APIs from JavaScript within Apollo applications.
Btw, ApolloAliases.js is a file included in the beta SDK that provides JavaScript aliases into ActionScript APIs to make them easier and more convenient to use from JavaScript.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK