|
|
|
Thumbnail Browser
Added on 8/15/1999
|
Drop this on a field or text member and input the correct values. Use the sendSprite command to send the search (buildList) and browse button (advance) commands
property imageSprite, whichCasts, imageList, currentList, currentItem, spriteNum
on getPropertyDescriptionList me
if getOne([#field, #text], sprite(the currentSpriteNum).member.type) = 0 and the currentSpriteNum > 0 then
alert "This is for text and field members only!"
exit
end if
p_list = [:]
p_list.addProp(#imageSprite, [#format : #integer, #comment : "Which sprite is the thumbnail image?", #default : 1])
p_list.addProp(#whichCasts, [#format : #string, #comment : "Which casts to search for thumbnails?(Separate with commas and no spaces.)", #default : "Internal"])
return p_list
end
on beginSprite me
imageList = []
--Get the list of casts
the itemDelimiter = ","
repeat with x = 1 to whichCasts.item.count
theCast = whichCasts.item[x]
--Get the list of graphics
repeat with y = 1 to the number of members of castlib theCast
if member(y, theCast).type = #bitmap then
imageList.add(member(y,theCast).name)
end if
end repeat
end repeat
imageList.sort()
--create the currentList
currentList = duplicate(imageList)
newText()
end
on mouseUp me
currentItem = the mouseLine
theImage = sprite(spriteNum).member.line[the mouseLine]
sprite(spriteNum).member.line[the mouseLine].hilite()
sprite(imageSprite).member = member(theImage)
end
on buildList me, whatString
currentList = []
repeat with x = 1 to imageList.count
if imageList[x] contains whatString then
currentList.add(imageList[x])
end if
end repeat
newText()
end
on newText me
theString = ""
repeat with x = 1 to currentList.count
theString = theString & currentList[x]
if x < currentList.count then theString = theString & return
end repeat
sprite(spriteNum).member.text = theString
currentItem = currentList.getOne(sprite(imageSprite).member.name)
if currentItem > 0 then
sprite(spriteNum).member.line[currentItem].hilite()
else if currentList.count = 0 then
sprite(imageSprite).member = 0
else
sprite(imageSprite).member = member(currentList[1])
sprite(spriteNum).member.line[1].hilite()
currentItem = 1
end if
end
on advance me, howFar
if currentList.count > 0 then
newItem = currentItem + howFar
if newItem < 1 then
repeat while newItem < 1
newItem = newItem + currentList.count
end repeat
end if
if newItem > currentList.count then
repeat while newItem > currentList.count
newItem = newItem - currentList.count
end repeat
end if
currentItem = newItem
sprite(imageSprite).member = member(currentList[currentItem])
sprite(spriteNum).member.line[currentItem].hilite()
end if
end
on getBehaviorDescription me
return "This behavior sets up a field or text member as a browser for images in a cast. Drop it on the field member and tell it which sprite contains the thumbnail and a list of all casts to use. To do a search send the sprite a buildList statement (sendSprite(x, #buildList, " & quote & "searchword" & quote & ")) and to auto advance use the advance command with the number of frames to move (sendSprite(x, #advance, -1))"
end
|
|