如何实现director和flash通信

      DirectorFAQ 2005-6-2 9:26:00
Flash To Director的信息传递:
一般来说,Flash给Director传递消息有下面三个方法:
(1)在flash中可以通过Geturl函数直接调用Director的Lingo命令,如
on (rollover)
{ geturl (‘‘lingo:cursor 280‘‘);}
on (rollout)
{ geturl (‘‘lingo:cursor 0‘‘);}
将上面的actionscript加在flash按钮上,然后将其导入到Director中就能实现光标的变换了。

(2)使用flash中的event命令,如:
geturl (“event:readtxt,\”aa.txt\”,\”dairy\””)
上面的actionscript可以执行director中的影片脚本中的readtxt函数,并传递“aa.txt”和“dairy”两个参数给readtxt函数。

(3)在Flash中通过Geturl传送参数给Director,在Director中接受Flash传递的参数,然后执行相应的lingo命令,如:
在flash的按钮上加入下面的ctionscript
On (Release)
Get URL ("botton1")
End On
然后在DR的moviescript中,使用geturl函数执行相应的lingo命令:
on geturl me,kk –kk为geturl函数的参数
case kk of
"botton1": go to frame "Mark1"
"botton2": go to frame "Mark2"
end case
end geturl

Director To Flash的信息传递:
在Director中对flash的信息传递的指令相对要丰富得多
(1)在Director中控制flash演员播放、停止等命令
sprite(FlashSpriteNum).play() --播放 flash 演员
sprite(FlashSpriteNum).stop() –停止flash演员的播放
类似的函数有 rewind()、gotoframe() 等等。

(2)使用getVariable函数来直接获取flash演员中的值
getVariable(sprite FlashSpriteNum, “password”)
--获取位于通道FlashSpriteNum中的flash演员中变量password的值

(3)使用setVariable函数来设置flash演员中的值
setVariable(sprite FlashSpriteNum, “password”, “admin”)
--将位于通道FlashSpriteNum中flash演员中的password变量的值设置为admin

标签集:TAGS:
回复Comments() 点击Count()
喜欢就顶一下

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}