#22003/7/16 0:51:10
你那里有不明白之处?
这代码已经很简洁了....
property pMemRef
property pHyperlinkList
on beginSprite me
pMemRef = sprite(me.spriteNum).member---设定变量指代当前精灵在演员表中位置,这里是(member 1 of castLib 1)
me.buildHyperlinkList() ---由自定义buildHyperlinkList函数获取当前精灵超链接对应文本行列表
pMemRef.scrollTop = 0---等价于member(1).scrolltop=0
end
on buildHyperlinkList me----以下为自定义buildHyperlinkList函数
pHyperlinkList = [:]---初始化pHyperlinkList属性列表
tempList = pMemRef.hyperlinks---得到当前精灵的所有超链接区域列表
repeat with i = 1 to tempList.count---tempList.count列表的条目的个数
tempLink = pMemRef.char[ templist[i][1] ].hyperlink----得到变量tempLink为第i个数据得超链接
if tempLink starts "Anchor:" then---如果变量tempLink的开始字母为"Anchor:"那么
tempLink = value( "#" & tempLink.word[2])---变量tempLink等于变量tempLink的第二个词
pHyperlinkList.addProp(tempLink, tempList[i][1] - 1)---在属性列表增加以变量tempLink为属性,当前范围的前一字节为数据的一项
end if
end repeat
end
on hyperlinkClicked me, data, range---当点击在超链接上(此句极其参数为lingo固定用法,见帮助)
if data.char[1] = "#" then----如果data的第一个字节为"#"(data为超链接的值)
destinationAnchor = value(data) ---去掉引号以便与pHyperlinkList属性列表对应
if not voidP(pHyperlinkList.getAProp(destinationAnchor)) then----如果在pHyperlinkList属性列表不是没有数据
if pHyperlinkList[destinationAnchor] <= 0 then----如果数据小于等于0
pMemRef.scrollTop = 0---
else
pMemRef.scrollTop = charPosToLoc(pMemRef, pHyperlinkList[destinationAnchor]).locV----lingo固定用法,得到当前字节的位置
end if
end if
end if
end
编辑历史:[这消息被54zq编辑过(编辑时间2003-07-16 01:37:22)]