Adobe Integrated Runtime (AIR) for JavaScript Developers Pocket Reference

(nextflipdebug5) #1
Sound | 137

file.upload( request, "image", false );
}

function doUpload( )
{
file.browseForOpen( "Select File" );
}
</script>

</head>
<body onload="doLoad( )">

<input id="btnUpload" type="button" value="Upload" />

<div id="txtProgress" style="visibility: hidden">
Uploading... 0%</div>

</body>
</html>

Sound


Playing a Sound


Problem


You need to play a sound in your application.


Solution


Use theSound API within AIR to play an MP3 file.


Discussion


AIR includes complete support for accessing Flash Player
APIs from JavaScript. This includes theSoundclass that can
be used to play local or remote MP3 files.


Playing a sound is simple, and requires two main steps:


1.Create aURLRequestinstance that references the local or
remote sound.
2.Pass theURLRequest to theSound instance, and play it.
Free download pdf