嘿,伙计们,我让ExternalInterface调用了一个javascript函数。但是,现在如何使用jQuery来定位调用该函数的.swf呢?
例如,我使用ExternalInterface调用"changeObject“函数。如何让jQuery修改相同的闪存文件对象标签?这就是我所拥有的,但它不起作用:
function changeObject()
{
jQuery(this).css('height','500px');
};jQuery(this) get返回为未定义。我不知道object元素的ID。这是一个动态ID,在一个页面上也会有多个.swf。
谢谢!
发布于 2010-11-17 01:34:03
所以我设置了一个新的Flashvar,它是一个独特的playerID。如下所示:
var flashvars = {};
flashvars.src = '<?= $this->get('link') ?>';
flashvars.playerID = '<?= "flash-".uniqid(); ?>';
var params = {};
params.allowscriptaccess = 'always';
var attributes = {};
attributes.id = '<?= $this->get('attributeId') ?>';
swfobject.embedSWF('<?= $this->get('pluginUrl') ?>/flash/wiredrivePlayer.swf', 'no-flash-content', '100%', '100%', '10.0.0', 'expressInstall.swf', flashvars, params,attributes);然后我在ActionScript语言中设置Flashvar (在Model.as中):
// Add into the "Declare private vars" section
private var _playerID:String;
// Add into the private function init(flashvars:Object) section
_playerID = flashvars.playerID;
//Add into the public functions section
public function get playerID():String {
return _playerID;
}
//Add into the public function endOfItem() section
// inform JavaScript that the FLV has stopped playing
ExternalInterface.call("stoppedPlaying", _playerID); 然后在Javascript中,我现在可以像这样使用playerID:
function stoppedPlaying(playerID)
{
// do something when the FLV starts playing
var playerID = '#' + playerID
jQuery(playerID).css('background','red');
}因此,我只使用arg playerID而不是jQuery中的(this)。太高兴了!
发布于 2010-11-16 06:41:16
我不认为有任何方法可以获取调用者对象,但一种解决方案是向该changeObject函数添加一个属性,并将swf的id传递给您的Flash应用程序。
发布于 2010-11-16 06:41:24
我快速浏览了一下文档,这似乎是不可能的(但我很可能是错的,请对这个主题有更多了解的人纠正我)。
您可以尝试使用标识符初始化每个swf,然后在每次函数调用时传递回该标识符(该标识符将与swf对象的ID匹配)。
https://stackoverflow.com/questions/4189442
复制相似问题