主题:  弹出菜单的问题

zhangkui

职务:普通成员
等级:1
金币:0.0
发贴:58
注册:2001/3/10 1:52:11
#12002/5/8 0:34:16
我做了一个简单的弹出菜单,用如下语句使其在鼠标进入时弹出,离开时收回。
但是当实际使用时,出现问题了,弹出弹进都没问题,可是如果连接层在菜单后方,
菜单就会把连接给屏蔽了,鼠标指示不起作用
如果连接层在菜单前方,则鼠标进入连接层时,菜单认为mouseleave,就收回去了,真的没办法了,
请各位高手指点一二,做一个简单的弹出菜单怎么办?

on mouseenter me
if sprite (the currentSpriteNum) .loch sprite (the currentSpriteNum) .loch=sprite (the currentSpriteNum) .loch+pstepvalue
else
end if
end

on mouseleave me
if sprite (the currentSpriteNum) .loch > pminloch then
sprite (the currentSpriteNum) .loch = pminloch
else
end if
end



lindmoo

职务:普通成员
等级:1
金币:0.0
发贴:19
注册:2001/10/14 17:25:44
#22002/5/8 9:01:21
那你的离开时的语句就不要用the currentspritenum了呀,换成真正的spritenum,这样应该是可以的



zhangkui

职务:普通成员
等级:1
金币:0.0
发贴:58
注册:2001/3/10 1:52:11
#32002/5/8 11:04:43
谢谢回复,我实验了一下,还是不成啊,我把所有的the currentSpriteNum都改成真正的spriteNum,结果还是一样。我觉得是不是DIRECTOR认为两个不同的SPRITE相重合时,只有上面的才起作用呢?



lindmoo

职务:普通成员
等级:1
金币:0.0
发贴:19
注册:2001/10/14 17:25:44
#42002/5/8 11:52:41
当然了,前面的sprite肯定会挡住后面的呀
我理解你的意思了
看一下这样可以吗
那你的离开时的语句不要直接对你的菜单写,你可以将菜单和连接层用lingo连起来,也就是在muse进入菜单后,菜单弹出,然后再做连接层的交互。
mouse离开的条件是对连接层和它们之间的孔隙-也就是菜单-做检测,如果检测到mouse不再这几部分内,就收回菜单
可能比较麻烦,有好方法我再来发

另外其实可以用installmenu来做的,只是字体等不能修改



zhangkui

职务:普通成员
等级:1
金币:0.0
发贴:58
注册:2001/3/10 1:52:11
#52002/5/8 13:50:13
谢谢,我现在是这么做的:
检测鼠标坐标,超出菜单的范围就收回菜单。
-----------------------------------
on mouseenter me
repeat while sprite (the currentSpriteNum).loch < pmaxloch
sprite (the currentSpriteNum).loch=sprite (the currentSpriteNum) .loch+(pstepvalue/10)
end repeat
end

on prepareframe me
if the mouseh>pright then
sprite (the currentSpriteNum) .loch = pminloch
else
if the mousev>pdown then
sprite (the currentSpriteNum) .loch = pminloch
else
if the mousev sprite (the currentSpriteNum) .loch = pminloch
end if
end if
end if
end
----------------------------------------------------------
可以用了,还有一点小问题,我想让菜单弹出时不是一下出来,
而是有一个移动过程的。我曾试用onmousewithin me可以作到,
但还是会有连接层阻挡这个问题
用repeat语句后一下就出来了,是不是机器太快了 :)
你有什么更好的建议?请指教。






night_5d

职务:普通成员
等级:2
金币:1.0
发贴:275
注册:2000/12/15 21:24:38
#62002/5/8 21:22:34
可以做一个运动函数,在exitframe中加一个判断,然后让他运动不就行了


[img]http://61.144.28.245/hjc/web/non-cgi//usravatars/paladin.gif[/img]
I thirst for freedom

zhangkui

职务:普通成员
等级:1
金币:0.0
发贴:58
注册:2001/3/10 1:52:11
#72002/5/9 1:35:26
您说的对,可我是菜鸟,能否给个小小提示?



night_5d

职务:普通成员
等级:2
金币:1.0
发贴:275
注册:2000/12/15 21:24:38
#82002/5/9 10:13:46
on moveMenu mystate
case mystate of
"up":
if sprite(me.spritenum).locv>uploc then
sprite(me.spritenum).locv=sprite(me.spritenum).locv-1
end if
"down":
if sprite(me.spritenum).locvsprite(me.spritenum).locv=sprite(me.spritenum).locv+1
end if
otherwise:
end case
end

on exitframe
moveMenu(mystate)
end

简单写了一个思路,根据实际情况自己调试。


[img]http://61.144.28.245/hjc/web/non-cgi//usravatars/paladin.gif[/img]
I thirst for freedom

zhangkui

职务:普通成员
等级:1
金币:0.0
发贴:58
注册:2001/3/10 1:52:11
#92002/5/9 19:00:24
不愧是终极用户耶!让我顿开茅塞。高手啊高手。论坛有您这样的人才会发展的红火!顺便问一下,高级和终极用户是不是只要回帖多就可以坐到的啊?



zhangkui

职务:普通成员
等级:1
金币:0.0
发贴:58
注册:2001/3/10 1:52:11
#102002/5/10 0:55:29
我的结果如下,达到我想要的目的了。
算是给帮助过我的人的回答,感谢你们。
也给有过类似困扰的人一点提示
-------------------------------
on beginsprite me
penter = false
end

on mouseenter me
penter = true
end

on prepareframe me
if penter then
if pcurrentlocv < pmaxlocv then
pcurrentlocv = pcurrentlocv +pmoveamount
sprite(me.spritenum).locv = pcurrentlocv

else
end if
end if

end
----------------------------------------



zhangkui

职务:普通成员
等级:1
金币:0.0
发贴:58
注册:2001/3/10 1:52:11
#112002/5/10 1:31:40
不对了,我的方法还是不行,出来没事了,鼠标离开时菜单回不去。
真奇怪,我还是没吃透啊,只好再研究了。



zhangkui

职务:普通成员
等级:1
金币:0.0
发贴:58
注册:2001/3/10 1:52:11
#122002/5/16 14:43:17
研究成果:
on mouseenter me
repeat with i=1 to 100
sprite(me.spritenum).locv=sprite(me.spritenum).locv+1
updatestage
end repeat
end
离开时用检测鼠标坐标方式,才不会受到不必要的mouseleave事件

一点心得:mouseenter mouseleave是一次性的事件,用repeat来保证其动作的完成。而不会受到在上面的sprite 的干扰。
而mousewithin是持续的事件,当有另一个sprite在其上面时,会引起mousewithin的false






hanshan

职务:普通成员
等级:1
金币:0.0
发贴:85
注册:2001/7/13 13:14:08
#132007/5/3 17:06:04
能不能实现二级菜单问题,以及如何加链接呢?