所以我設置了一個新的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