使用AS3多个SWF通信 [英] multiple swf communication using as3
本文介绍了使用AS3多个SWF通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要: 如果我播放一个SWF,其他主权财富基金应暂停,如果被打。
我能沟通使用JavaScript两个SWF(包括主权财富基金是不同的名称)。但前来多个主权财富基金,我不知道如何区分主权财富基金东阳都是相同的名称。
我已经尝试使用下面的脚本嵌入到我html页面3 SWF文件。
<$p$p><$c$c>swfobject.embedSWF('http://webserver/aruldass/versemusic/modules/mod_playerjr/player-songs.swf', jwplayer1','280','230','9',假的,Flash变量,参数,可以属性); swfobject.embedSWF('HTTP://webserver/aruldass/versemusic/modules/mod_playerjr/player-songs.swf','jwplayer2','280','230','9',假的,Flash变量,参数,可以属性) ; swfobject.embedSWF('HTTP://webserver/aruldass/versemusic/modules/mod_playerjr/player-songs.swf','jwplayer3','280','230','9',假的,Flash变量,参数,可以属性) ;
我要相互沟通。
与我们分享您的想法。
解决方案
嗯,我想我会解决这个问题的方式如下:
- 修改SWF生成在创建一个随机ID
- 添加有一个id值作为参数,并呼吁所有的SWF中的pre定义函数的JavaScript函数(比方说
processPlayEvent(ID:字符串):无效
- 使用闪光灯
ExternalInterface的
来调用该函数传入当前SWF ID作为参数 - 在
processPlayEvent
功能,您检查所提供的ID等于当前的电影之一。如果他们是不平等的,要暂停当前SWF的播放。
My need : If I playing one swf, the other swfs should pause if it was playing.
I can able to communicate two swfs using javascript(both swfs are different name). But come to multiple swfs, I don't know how to differentiate the swfs beacause all are same name.
I have embed 3 swf files in my html page using the following script.
swfobject.embedSWF('http://webserver/aruldass/versemusic/modules/mod_playerjr/player-songs.swf', 'jwplayer1', '280', '230', '9', false, flashvars, params, attributes);
swfobject.embedSWF('http://webserver/aruldass/versemusic/modules/mod_playerjr/player-songs.swf', 'jwplayer2', '280', '230', '9', false, flashvars, params, attributes);
swfobject.embedSWF('http://webserver/aruldass/versemusic/modules/mod_playerjr/player-songs.swf', 'jwplayer3', '280', '230', '9', false, flashvars, params, attributes);
I want to communicate each other.
Share your ideas.
解决方案
Well I think I would solve this problem the following way:
- Modify the SWF to generate a random id upon creation.
- Add a JavaScript function that has an id-value as parameter and calls a pre-defined function on ALL the SWF (let's say
processPlayEvent(id:String):void
- Use the Flash
ExternalInterface
to call that function passing the current SWF Id as a parameter - Inside the
processPlayEvent
function you check if the provided id equals the one of the current movie. If they are unequal, you halt the playback of the current SWF.
这篇关于使用AS3多个SWF通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文