I have a function in my swf file: playSound() which I can call via jQuery like so:
$.talkToFlash("interfaceSounds").playSound();
whereas ‘talkToFlash’ simply returns the swf file. This part is well documented on here and works fine.
But, how do I pass a parameter?
I believe in JS this would be:
$.talkToFlash("interfaceSounds").playSound('swish.mp3');
But what do I do in AS3?
I tried amending my initial working functions:
function playSound() {
var s:swishSound = new swishSound;
var channel:SoundChannel = s.play();
}
ExternalInterface.addCallback("playSound", playSound);
with this:
function playSound(mp3file) {
trace(mp3file);
}
But ‘mp3file’ is just empty. I tried
ExternalInterface.addCallback("playSound", playSound(mp3file));
and other variations of this ‘theme’, but nothing seems to work. Am I just struggling with syntax here or this there more to it? Thanks for your help.
Turns out was correct to start with. The error lied somewhere else, I’d forgotten to embed a font :/
Nevertheless, for those who build a similar thing, here’s the complete Code. I’m also not sure if my method of stopping a track is correct, so any improvements most welcome 🙂
AS3:
And in jQuery:
And HTML/PHP:
I also have a technique that might be worth sharing as I foundd this very usesful when developing with Flash. You can easily change appearance of the container or burst a cache if you set up some vars in PHP that configure your Flash:
In your php doc later you just echo it where ever you want: