主题:  如何制作自定义的文本滚动条!

firstep

职务:普通成员
等级:1
金币:0.0
发贴:28
#12001/5/16 11:16:09
请问各位高手!如何制作自定义的文本滚动条!谢谢谢谢!

编辑历史:[这消息被firstep编辑过(编辑时间2001-05-16 11:16:35)]


zch3

职务:普通成员
等级:1
金币:0.0
发贴:25
#22001/5/16 15:07:50
property pChannel_huakuai -- 滑动块的通道号 n
property pChannel_huagan -- 滑动杆的通道号n-1
property pChannel_Text -- 视屏文字域的通道号 n-2
property pTotalHeight --文字的实际总高度
property pHuakuai_Top -- 滑动杆所能到的最高偏移值(pixel计算)
property pHuakuai_Bottom -- 滑动杆所能到的最低偏移值(pixel计算)
property pHuakuai_Range -- 滑动杆所能移动范围(pixel计算)
property pConstant

on beginsprite me
pChannel_huakuai = me.spritenum
pChannel_huagan =me.spritenum-1
pChannel_Text = me.spritenum-2

pTotalHeight=sprite(pChannel_Text).member.height-sprite(pChannel_Text).height
pHuakuai_Top = sprite(pChannel_huagan).top + sprite(pChannel_huakuai).height/2
pHuakuai_Bottom = sprite(pChannel_huagan).bottom - sprite(pChannel_huakuai).height/2
pHuakuai_Range = pHuakuai_Bottom - pHuakuai_Top
pConstant=pTotalHeight/pHuakuai_Range

sprite(pChannel_huakuai).locv=sprite(pChannel_huagan).top+sprite(pChannel_Huakuai).height/2

end

on mouseenter me
cursor 280
end

on mouseleave me
cursor -1
end

on mousedown me
repeat while the mouseDown
set newMouseV = the mouseV

if newMouseV >= pHuakuai_Bottom then
set newMouseV = pHuakuai_Bottom
else if newMouseV <= pHuakuai_Top then
set newMouseV = pHuakuai_Top
end if

deltaY=newMouseV-pHuakuai_Top
sprite(pChannel_text).member.scrolltop = deltaY*pConstant

sprite(pChannel_huakuai).locV = newMouseV
updateStage
end repeat
end