|
|
|
Faux Marquee Tool
Added on 12/17/1999
|
This behavior simulates a marque tool in Director. Make 2 quick-draw squares and create custom patterns for horizontal and vertical stripes. Make at least 2 frames of each, offset slightly. Place 2 of each quickDraw shapes on the stage and drop the behavior on top. Assign the number of the patters(get it with put member(x).pattern) and then apply it to a background sprite as well. The resulting rectangle is stored in the global variable selectedRect. An example is available in articles section of MediaMacros at www.mediamacros.com/howto.shtml
--Copyright 1999 Chuck Neal
--chuck@mediamacros.com
--If you find this code helpful, send me an e-mail and let me know. :-)
property spriteNum, whatPiece, patternList, whatPattern
global selectedRect
on getPropertyDescriptionList me
p_list = [:]
p_list.addProp(#whatPiece, [#format : #symbol, #comment : "Which side of the marque:", #default : #top, #range : [#Top, #Left, #Right, #Bottom, #BG]])
p_list.addProp(#patternList, [#format : #string, #comment : "Pattern Numbers:", #default : "57,58"])
return p_list
end
on mouseDown me
if whatPiece = #bg then
--it is the bg, set a new marque
startPoint = the mouseLoc
repeat while the stillDown
mousePoint = the mouseLoc
if mousePoint.locH > sprite(spriteNum).rect.right then
mousePoint.locH = sprite(spriteNum).rect.right
else if mousePoint.locH < sprite(spriteNum).rect.left then
mousePoint.locH = sprite(spriteNum).rect.left
end if
if mousePoint.locV > sprite(spriteNum).rect.bottom then
mousePoint.locV = sprite(spriteNum).rect.bottom
else if mousePoint.locV < sprite(spriteNum).rect.top then
mousePoint.locV = sprite(spriteNum).rect.top
end if
hList = [startPoint.locH, mousePoint.locH]
vList = [startPoint.locV, mousePoint.locV]
sort(hList)
sort(vList)
theRect = rect(hList[1],vList[1], hList[2], vList[2])
sendAllSprites(#makeMarque, theRect)
updateStage
end repeat
if startPoint = the mouseLoc then
selectedRect = rect(0,0,0,0)
sendAllSprites(#moveOff)
else
mousePoint = the mouseLoc
if mousePoint.locH > sprite(spriteNum).rect.right then
mousePoint.locH = sprite(spriteNum).rect.right
else if mousePoint.locH < sprite(spriteNum).rect.left then
mousePoint.locH = sprite(spriteNum).rect.left
end if
if mousePoint.locV > sprite(spriteNum).rect.bottom then
mousePoint.locV = sprite(spriteNum).rect.bottom
else if mousePoint.locV < sprite(spriteNum).rect.top then
mousePoint.locV = sprite(spriteNum).rect.top
end if
hList = [startPoint.locH, mousePoint.locH]
vList = [startPoint.locV, mousePoint.locV]
sort(hList)
sort(vList)
theRect = rect(hList[1],vList[1], hList[2], vList[2])
sendAllSprites(#makeMarque, theRect)
selectedRect = theRect
end if
end if
end
on beginSprite me
selectedRect = rect(0,0,0,0)
moveOff()
whatPattern = 1
end
on makeMarque me, whatRect
case whatPiece of
#top :
sprite(spriteNum).rect = rect(whatrect[1] - 1, whatRect[2] - 1, whatrect[3] + 1, whatRect[2])
#bottom :
sprite(spriteNum).rect = rect(whatrect[1] - 1, whatRect[4], whatrect[3] + 1, whatRect[4] + 1)
#left :
sprite(spriteNum).rect = rect(whatrect[1] - 1, whatRect[2] , whatrect[1] , whatRect[4])
#right :
sprite(spriteNum).rect = rect(whatrect[3], whatRect[2] , whatrect[3] + 1, whatRect[4])
end case
end
on moveOff me
if whatPiece <> #bg then
sprite(spriteNum).rect = rect(-1000, -1000, -1000, -1000)
end if
end
on exitFrame me
if whatPiece <> #BG then
the itemDelimiter = ","
whatPattern = whatPattern + 1
if whatPattern > patternList.item.count then whatPattern = 1
sprite(spriteNum).member.pattern = integer(patternList.item[whatPattern])
end if
end
on getBehaviorDescription me
describe = "This behavior simulates a marque tool in Director."
describe = describe & return & "Make 2 quick-draw squares and create custom patterns for horizontal and vertical stripes. Make at least 2 frames of each, offset slightly."
describe = describe & return & "Place 2 of each quickDraw shapes on the stage and drop the behavior on top. Assign the number of the patters(get it with put member(x).pattern) and then apply it to a background sprite as well. The resulting rectangle is stored in the global variable selectedRect"
describe = describe & return & return & "An example is available in articles section of MediaMacros at www.mediamacros.com/howto.shtml"
return describe
end
|
|