我正在尝试从我的JavaScript调用我的ActionScript中的一个函数,我已经成功地用另一个闪存文件调用了一个函数,但在当前的闪存文件中,由于某种原因它失败了。我使用的是jQuery SWFEmbed,这是我的JS代码:
$.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());
}
});这是我的AS代码,这是在我的构造函数中:
public function reproductor()
{
ExternalInterface.addCallback("callIt", test);
ExternalInterface.call("alert", "Que fue?");
trace(ExternalInterface.available);
}这是我的函数:
private function test():String {
return "this is a test";
}ExternalInterface.call正常工作,并且跟踪输出为真,我不知道发生了什么。
附言:如果您还能告诉我如何将参数传递给ExternalInterface回调,我将不胜感激。
发布于 2011-10-27 06:51:50
要在回调函数中接收参数,只需通过JS发送它,并在回调函数中将其作为参数接收。示例:
$('.player.active > object')[0].callIt("LOLSOME")
...
ExternalInterface.addCallback("callIt", test);
private function test(arg:String):String {
return "param received from JS: " + arg;
}https://stackoverflow.com/questions/7909630
复制相似问题