#22000/11/30 11:33:20
下面是滚动条的行为:
property pchThumb -- 滑动块的通道号 n
property pchScrollBar -- 滑动杆的通道号n-1
property pOnScreenField -- 视屏文字域的通道号 n-2
property pTotalHeight --文字域的实际总高度
property pThumbTop -- 滑动杆所能到的最高偏移值(pixel计算)
property pThumbBottom -- 滑动杆所能到的最低偏移值(pixel计算)
property pThumbRange -- 滑动杆所能移动范围(pixel计算)
on beginsprite me
set pchThumb = me.spritenum
set pchScrollBar =me.spritenum-1
set pOnScreenField = me.spritenum-2
set pTotalHeight=the height of the member of sprite pOnScreenField-the height of sprite pOnScreenField
set pThumbTop = the top of sprite pchScrollBar + (the height of sprite pchThumb / 2)
set pThumbBottom = the bottom of sprite pchScrollBar - (the height of sprite pchThumb / 2)
set pThumbRange = pThumbBottom - pThumbTop
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 >= pThumbBottom then
set newMouseV = pThumbBottom
else if newMouseV <= pThumbTop then
set newMouseV = pThumbTop
end if
set deltaY=newMouseV-pThumbTop
set the scrolltop of the member of sprite pOnScreenField=pTotalHeight*float(deltaY)/pThumbRange
set the locV of sprite pchThumb = newMouseV
updateStage
end repeat
end
--滚动条
--使用方法
--1、文本放在n-2号通道
-- 滑轴放在n-1号通道
-- 滑块放在n号通道
-- 上述三个精灵所在的通道必须连续,
-- 如1,2,3或者10,11,12等。
--2、将"Scroll"行为直接拖到滑块精灵上即可