|
Director 8从入门到精通(九)
|
|
胡飞 4月13日 ChinaByte网络学院
|
如果按下了回车键,判断域文本内容是否正确
on CheckEnter
if keypressed(Return) then
checkanswers
end if
end
--判断用户给出的答案是否正确
on checkanswers
--check if the answers are correct or not
--将开发人员提供的三个正确答案加入到列表Parameters中
parameters = [FirstAnswer,SecondAnswer,ThirdAnswer]
--如果答案正确则执行开发人员定义的消息MessageCorrect
if getpos(parameters,mymember.text ) then
do messageCorrect
--否则执行MessageIncorrect
else
do messageIncorrect
end if
end checkanswers
--判断与本行为联系的对象类型是不是域文本
on isOKToAttach (me, SpriteType, aSpriteNum)
--If the member type is either #field or #text then
--return true
--else return false
case SpriteType of
#graphic:
if sprite(aspriteNum).member.type = #field then
return True
else if sprite(aspriteNum).member.type = #Text then
alert "In this version, the member type must be field, not surport text."
return false
end if
#script:
return FALSE
end case
end isOKToAttach
--设置相对于多媒体开发人员的用户界面和参数
on getPropertyDescriptionlist
--get the answers the developer gave
ParameterList = [:]
setaprop ParameterList, #FirstAnswer,
[#comment: "Input the first correct answer: ",
#format: #string, #default: Empty]
setaprop ParameterList, #SecondAnswer,
[#comment: "Input the second correct answer: ",
#format: #string, #default: Empty]
setaprop ParameterList, #ThirdAnswer,
[#comment: "Input the third correct answer: ",
#format: #string, #Default: Empty]
setaprop ParameterList, #MessageCorrect,
[#comment: "If the answer is correct ,do message: ",
#format: #string, #default: "Nothing"]
setaprop ParameterList, #MessageIncorrect,
[#comment: "If the answer is incorrect ,do message: ",
#format: #string, #Default: "Nothing"]
return ParameterList
end getPropertyDescriptionlist
以上是“Check Answer”行为的全部脚本。将其加入到系统路径的
…/director 8/libs下的“Text.cst”中,作为一个完整的行为来调用。经测试,该行为达到预期目标。
开发人员使用该行为时界面如下:
“Check Answer”行为的参数设置
在Director中,还提供了开放式的外部插件方式,即Xtras。下面我们做一个简单的例子说明Xtras插件的编写。
任意做一个Director项目,比如在舞台上加入一个域文本,输入“Hello”,设置舞台和精灵属性,保存。选择菜单File/Publishing settings项,在Formats页中设置“HTML Tamplate”为“Shockwave Default”,设置“ShockWave file”为“hello.dcr”,确定。再选择File/Publishing项,就生成了“hello.dcr”文件。
将“hello.dcr”拷贝到系统路径…/Director 8/Xtras中,重新启动Director 8,在菜单Xtras 中就可以发现Hello了。当然,它不起任何作用,这里只是给出了编写Xtras的一种方法。有兴趣的朋友可以试试编写一个有实际功能的插件,如果你的插件能够正确使用,那么你对Director的掌握已经很有火候了,并且对各种关系已经理得很顺了。
要想在创作中得心应手,还必须熟练掌握其它应用软件的使用方法,象声音处理软件、图形图象处理软件等等,此外还要求开发人员具备一定的美术功底和较好的审美观,能够将一个好的创意用多媒体技术实现出来。所谓“熟能生巧”,只要多看、多学、多做、多思,你就会成为一名出色的导演!
申明:本文中的所有脚本均由本人编写,并在Director8中调试通过,画图的脚本因篇幅所限未能全部给出,感兴趣的朋友可以与我联系;“Check Answer”行为脚本未经本人同意,禁止用做商业用途。
|
|
|