-- scripts
on beginSprite me
-- checks whether sprite(me.spriteNum).member is a valid member
if sprite(me.spriteNum).member.type <> #Field then
alert "JTMR KoolMarquee" & Return & "Use this behavior with a field member."
me.status = #error
return 0
end if
on endSprite me
if me.status = #error then return 0
me.contentMember.text = ""
sprite(me.spriteNum).member.text = ""
end endSprite
on prepareFrame me
if me.status = #error then return 0
if me.deltaScroll <= 1 then
sprite(me.spriteNum).locH = me.initialLocH
sprite(me.spriteNum).member.text = JTMRgetMarqueeText(me)
else
sprite(me.spriteNum).locH = me.initialLocH - me.currentDeltaScroll
me.deltaScroll = me.deltaScroll - 1
me.currentDeltaScroll = me.currentDeltaScroll + 1
end if
end prepareFrame
on JTMRgetMarqueeText me
if me.status = #error then return 0
myCC = me.contentMember.text.length
me.currentLetter = JTMRturningNumber(me.currentLetter+1, 1, myCC)
myStartPos = charPosToLoc(me.contentMember, me.currentLetter)[1]
myLastLetter = min(me.currentLetter+1, myCC)
repeat while charPosToLoc(me.contentMember, myLastLetter)[1]-myStartPos < me.marqueeWidth
myLastLetter = myLastLetter + 1
if myLastLetter > myCC then
exit repeat
end if
end repeat
me.deltaScroll = charPosToLoc(me.contentMember, min(me.currentLetter+1, myCC))[1] - myStartPos
me.currentDeltaScroll = 1
return me.contentMember.text.char[me.currentLetter..myLastLetter]
end JTMRgetMarqueeText
on JTMRsetMarqueeText me, pText
if me.status = #error then return 0
me.contentMember.text = pText
i = 1
repeat while charPosToLoc(me.contentMember, i)[1] < me.marqueeWidth
me.contentMember.text = " " & me.contentMember.text
i = i + 1
end repeat
end JTMRsetMarqueeText
-- =================
-- MISC.
-- =================
on JTMRturningNumber pNumber, pMin, pMax
case JTMRisBetween(pNumber, pMin, pMax) of
0 : return pNumber
-1 : return pMax
1 : return pMin
end case
end JTMRturningNumber
on JTMRisBetween pNumber, pMin, pMax
if pNumber < pMin then
return -1
end if
if pNumber > pMax then
return 1
end if
return 0
end JTMRisBetween
-- ==================================================
on getPropertyDescriptionList
myPropertylist = [:]
addProp myPropertyList, #contentMember, [#Comment: "Choose a clone field of your 'marquee' field ", #format: #field, #default: 0]
return myPropertyList
end getPropertyDescriptionList
on getBehaviorDescription
return "JTMR Behavior Library" & RETURN &") 2000 - JTMR" & RETURN &"jtmr@worldnet.fr" & RETURN & "http://www.jtmr.fr.st" & RETURN & RETURN & "JTMR KoolMarquee Behavior" & RETURN & RETURN & "This behavior works only with field member." & RETURN & RETURN & "use sendSprite(x, #JTMRsetMarqueeText, " & QUOTE & "Blah Blah Blah Blah..." & QUOTE & ")" & RETURN & RETURN & "This behavior is free software; you can redistribute it and/or modify " & "it under the terms of the GNU General Public License as published by " & "the Free Software Foundation; either version 2 of the License, or (at " & "your option) any later version. " & "This program is distributed in the hope that it will be useful, but " & "WITHOUT ANY WARRANTY; without even the implied warranty of " & "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU" & "General Public License for more details." & "You should have received a copy of the GNU General Public License" & "along with this program; if not, write to the Free Software " & "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA."
end getBehaviorDescription