 |
|
 |
| 您现在的位置: 先创网 >> 媒体动画 >> Director >> 文章正文 |
|
|
| Director 制作具有Win XP 风格的菜单(2) |
| 网络文摘 |
| 2005-10-16 11:36:19文/佚名 |
|
|
|
|
|
Director 制作具有Win XP 风格的菜单 4 .撰写 lingo 脚本
( 1 )程序构思: 当用户在舞台范围内点击鼠标右键时,在鼠标右键点击的位置,淡入淡出地弹出(显示)一个快捷菜单,让用户选择他要观看的内容,按下鼠标左键后选定内容,然后让计算机执行相应的演示。
( 2 )程序实现
a. 编写菜单控制脚本(响应范围是全局的),按 打开脚本编辑窗口,起名为 “Menu Control Script” ,按脚本编辑窗口右上角的 (属性)按钮,设置其脚本类型( type )为 “movie” 。
然后在脚本编辑窗口里写入以下脚本:
-- 程序初始化
on startMovie
-- 开始时菜单应为不可见 , 直到用户点击鼠标右键时才显示 , 所以先隐藏菜单
HideMenu
-- 初始化菜单和菜单阴影的基点 ( 使其能显示在正确的位置 )
set the regpoint of member "menu" to point(0,0)
set the regpoint of member "shadow" to point(0,0)
alert“ 在舞台范围内按鼠标右键观看效果! ”
end startMovie
-- 显示菜单事件
on ShowMenu
-- 打开通道 2 至 12, 显示菜单和菜单选择棒 ( 由于选择棒的透明度 (blend) 为 0 所以暂时看不到 )
repeat with i=2 to 12
set the visible of sprite i to 1
end repeat
-- 设置菜单和阴影的位置为鼠标点击的位置 ( 使菜单能动态跟随鼠标 )
set the loc of sprite 2 to the mouseloc
set the loc of sprite 3 to the mouseloc
-- 菜单选择棒动态跟随菜单(以菜单的位置为基准坐标,相对地改变选择棒位置)
repeat with i=1 to 9
--96 是菜单选择棒相对于菜单水平坐标的偏移值
sprite (i+3).loch = sprite(3).loch + 96
--32 是菜单选择棒相对于菜单垂直坐标的偏移值
--19 是菜单棒的高度
sprite (i+3).locv = sprite(3).locv + 32 + (i-1)*19
end repeat
-- 菜单的淡入淡出效果 ( 透明度从 10 渐变到 100)
repeat with i=10 to 100
set the blend of sprite 3 to i
i=i+10
updateStage
end repeat
end
-- 隐藏菜单事件 ( 只是将通道 2 至 12 关闭,使其不可见 )
on HideMenu
repeat with i=2 to 12
set the visible of sprite i to 0
end repeat
end
b. 编写菜单项选择棒行为脚本(响应范围只限于赋予本行为的角色),按窗口上角的 按钮,新建一个脚本,起名为 “Show Bar Script” ,设置其脚本类型( type )为 “behavior” 。然后在脚本编辑窗口里写入以下脚本:
-- 当鼠标移入当前菜单选择棒时 , 即用户选中某菜单项了
-- 让鼠标指针变成小手形状 , 且把菜单选择棒的透明度改成 100( 完全可见 )
on mouseEnter
sprite (the currentSpriteNum).blend = 100
cursor 280
end mouseEnter
-- 当鼠标移出当前菜单选择棒时 , 即用户不选某菜单项了
-- 把鼠标指针还原成原来指针形状 , 且把菜单选择棒的透明度改成 0( 不可见 )
on mouseLeave
sprite (the currentSpriteNum).blend = 0
cursor -1
end mouseLeave
-- 当用户在某一菜单选择棒上按下鼠标时 , 执行相应的操作
on mouseDown
-- 通过 the currentSpriteNum( 鼠标点击的菜单选择棒的角色编号 ) 属性 ,
-- 可以让计算机知道用户选择的菜单项,进而使计算机做出相应的操作。
case (the currentSpriteNum) of
4:alert" 跳转到 Windows XP 画面 !"
5:alert" 跳转到 Windows 2000 画面 !"
6:alert" 跳转到 Windows NT workstation 4.0 画面 !"
7:alert" 跳转到 Windows NT Sever 4.0 画面 !"
8:alert" 跳转到 Windows ME 画面 !"
9:alert" 跳转到 Windows 98 画面 !"
10:alert" 跳转到 Windows 95 画面 !"
11:alert" 跳转到 Windows CE 3.0 画面 !"
12:alert" 跳转到 Windows NT Embedded 画面 !"
end case
end mouseDown
|
|
|
|
|
|
|
 |
|
 |
|
|
|