主题:  如何实现子菜单功能?

大风车

职务:普通成员
等级:1
金币:0.0
发贴:77
注册:2002/10/3 19:03:22
#12003/3/23 0:31:40
我想在Director中做一个子菜单功能,即是将鼠标浮放在一个按钮上时,就会出现子菜单,可将鼠标移动去选择相应的选项功能(并有焦点移动).这样的功能在网上经常可以看到.
请问在Director 中怎么实现?需要什么Xtras插件吗?
谢谢!



gracie

职务:普通成员
等级:1
金币:0.0
发贴:74
注册:2003/2/27 22:53:52
#22003/3/23 10:39:11
菜单功能用跑针的方法就能实现,或者做个LOOP动画用演员替换的方法 。 至于焦点移动做个鼠标跟随就可以了。
我这是最苯的方法,各位高手要是有什么高招请多指教。



天涯孤客

职务:普通成员
等级:1
金币:0.0
发贴:56
注册:2002/9/23 19:21:10
#32003/3/23 11:45:13
- Windows Standard Menu
-- [Parameter Note]
-- 1. pRootState: The state of root item.
-- 2. pNormalRoot: The member of the root item in the normal state.
-- 3. pRolloverRoot: The member of the root item in the rollover state.
-- 4. pChildList: The list for saving sprite number of child items.

property pRootState, pNormalRoot, pRolloverRoot, pChildList

on getPropertyDescriptionList me
myList = [:]
addProp myList, #pRolloverRoot, [#comment: "Rollover Root", #format: #member, #default: ""]
addProp myList, #pChildList, [#comment: "Child List", #format: #list, #default: []]
return myList
end

on isOKToAttach me, spriteType
if spriteType = #script then
return FALSE
else
return TRUE
end if
end

on getBehaviorDescription me
return "WINDOWS STANDARD MENU"&RETURN&"-- Copyright by alphachi"
end

on getBehaviorTooltip me
return "Windows Standard Menu"
end

on beginSprite me
pRootState = FALSE
pNormalRoot = sprite(me.spriteNum).member
HideMenu me
end

on mouseEnter me
pRootState = TRUE
end

on mouseLeave me
if sprite(pChildList[1]).visible then
pRootState = TRUE
else
pRootState = FALSE
end if
end

on mouseDown me
repeat with i in pChildList
sprite(i).visible = TRUE
end repeat
repeat with p = 1 to 100
repeat with q in pChildList
sprite(q).blend = p
updateStage
end repeat
end repeat
end

on HideMenu me
repeat with i in pChildList
sprite(i).blend = 0
sprite(i).visible = FALSE
end repeat
end

on exitFrame me
repeat with i in pChildList
if rollover(i) then
sprite(i).forecolor = 0
sprite(i).backcolor = 205
else
sprite(i).forecolor = 255
sprite(i).backcolor = 0
end if
end repeat
if the mouseDown then
if not rollover(me.spriteNum) then
pRootState = FALSE
end if
end if
if pRootState then
sprite(me.spriteNum).member = pRolloverRoot
else
sprite(me.spriteNum).member = pNormalRoot
HideMenu me
end if
end



大风车

职务:普通成员
等级:1
金币:0.0
发贴:77
注册:2002/10/3 19:03:22
#42003/3/23 19:27:27
能否请 天涯孤客 或其他高手用中文在程序中注释一下吗?
这么长的程序读起来是有点费劲的。
谢谢!



greatmaster

职务:普通成员
等级:1
金币:1.0
发贴:248
注册:2001/6/14 19:50:37
#52003/3/24 14:26:43
其实你完全可以用FLASH做一个子菜单。这样只会占用一个通道而且效果很丰富。



space80916

职务:普通成员
等级:1
金币:0.0
发贴:96
注册:2001/8/5 5:51:15
#62003/3/24 15:17:50
如果lingo可以实现的东西,就用lingo实现,同一个效果flash会占用director更多的资源,本身director就属于模块化,多层嵌套运行的效率不好。这种子菜单效果用lingo可以实现的很好,自己多搜索一下网络资源,相关讲解太多了。



天涯孤客

职务:普通成员
等级:1
金币:0.0
发贴:56
注册:2002/9/23 19:21:10
#72003/3/30 11:36:10
大风车说"能否请 天涯孤客 或其他高手用中文在程序中注释一下吗?
这么长的程序读起来是有点费劲的。
谢谢!"


--------------------------------------------------------------------------------

其实并不难理解.看来你对一般的行为编写过程不熟悉.我们编写的这个“Guide”行为本身非常简单,但却涵盖了一个完整行为所涉及的全部内容,因为无论一个行为多么复杂,其本身均由下面几部分组成:

  * Property变量的声明
  * getPropertyDescriptionList函数
  * runPropertyDialog函数
  * isOKToAttach命令
  * getBehaviorDescription函数
  * getBehaviorTooltip函数
  * 行为主体代码

  当然,这七个部分并不都是必需的。一般情况下,只需包含Property变量的声明、getPropertyDescriptionList函数和行为主体代码即可。

  只要把握住以上几点,我们便可以举一反三,编写更多的自定义行为来满足不同的需求。如果在编写行为时遇到了困难,可以参考Director库面板内置的一些简单行为,会有不小的收获。

建议你.把编写行为的基础筐架搞清楚.然后自己多看别人的代码编写.自己也要多动手
[/quote]

编辑历史:[这消息被天涯孤客编辑过(编辑时间2003-03-30 11:44:13)]


大风车

职务:普通成员
等级:1
金币:0.0
发贴:77
注册:2002/10/3 19:03:22
#82003/3/30 23:05:29
多谢 天涯孤客 的指教!
我得努力学习Lingo了,不能再Go来GO去了!