Reputation: 5836
I'm trying to call a function in my ActionScript from my JavaScript, I've managed to successfully do this with another flash file but in the current one it's failing for some reason. I'm using jQuery SWFEmbed, this is my JS code:
$.ajax({
url: '<?php echo $html->url(array('controller' => 'voicenotes', 'action' => 'get_url'), true);?>' + '/' + container.children('#VoicenoteVnid').val(),
dataType: 'json',
type: 'POST',
success: function(response) {
container.children('.voicenote-info').children('.player').addClass('active');
flashMovie = container.children('.voicenote-info').children('.player');
alert(flashMovie.html());
flashMovie.flash({
swf: '<?php echo $html->url('/files/flash/reproductor_compact.swf',true); ?>',
width: 240,
height: 40,
quality: "high",
wmode: "transparent",
allowscriptaccess: "always",
});
alert($('.player.active > object')[0].callIt());
}
});
And here is my AS code, this is in my constructor:
public function reproductor()
{
ExternalInterface.addCallback("callIt", test);
ExternalInterface.call("alert", "Que fue?");
trace(ExternalInterface.available);
}
And this is my function:
private function test():String {
return "this is a test";
}
The ExternalInterface.call work, and the trace outputs true, I have no idea what's going on.
P.S: If you could also tell me how I can pass parameters to a ExternalInterface callback I'd appreciate it.
Upvotes: 1
Views: 1603
Reputation: 5194
To receive a param within your callback function, just send it by JS, and receive it as an argument in your callback function. Ex.:
$('.player.active > object')[0].callIt("LOLSOME")
...
ExternalInterface.addCallback("callIt", test);
private function test(arg:String):String {
return "param received from JS: " + arg;
}
Upvotes: 2