所以我设置了一个新的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);
然后我设置的是Flash变数的动作(在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)。很高兴!
那么如何让ExternalInterface将对象的ID发送给JS函数呢?我正在使用swfObject动态地嵌入SWF。所以我认为这将与attributes.id设置有关。 – 2010-11-15 22:49:12
我试图找出它可能:http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html#objectID – 2010-11-16 00:11:26