--How to use:
--1. A 1 pixel dots of any color must be on/off the stage.
--2. Drag and drop this behavior on to the text sprite that should act as the menu.
--3. Select color values from 0 to 256 for the rollOver downState and the rearImageOver color.
--" "If you wish to link to other pages refine your linking according to pLineNum for example if you create a property list.....myLinks[1:yourLink, 2:thatLink].
-- Mark Steinwender
-- Created: 6.12.00
-- text member menu system
-- This behaviour uses a text field as a menu system
-- A one pixle bitmap or a vector can be used as a rollover that is place off the screen
-- or hidden as a color of the background. This image is resized according to
-- the width of the movie and the height of the line wrap
-- use this behaviour as you please.
--///////////////////////////////////////////////////////////////////////--
on beginSprite me
set pMySprite = the spriteNum of me -- get the sprite channel number
set pMyMemberName = sprite(pMySprite).member -- get the name of the cast member in the channel
initSpecifications() -- initinalize all the specs used for the text menu instance
resetColor(me,#all) -- set all the text color to the default just incase it was not turned off when the mouse left
end
--///////////////////////////////////////////////////////////////////////--
on initSpecifications me
set pLineNum = 900 -- an outrageous line num so when the mouse is within it will never = the currentLine num off the bat
set pFixedLineHeight = member(pMyMemberName).fixedLineSpace -- get the lineHieght of the text member
set pMyHeight = member(pMyMemberName).height
set pMyWidth = member(pMyMemberName).width
set pMyLeftPos = sprite(pMySprite).left
set pMyTopPos = sprite(pMySprite).top
set pMyKerning = member(pMyMemberName).kerningThreshold
set pMyCharWidth = (getAt(charPosToLoc(member(pMyMemberName), 3) ,1) - getAt(charPosToLoc(member(pMyMemberName), 2) ,1) )
set pMyLineList = wordWrapWorkAround() -- creates a list if the line is wraped on two lines then it sets its value to 2 (line is wraped over two lines)
set pMyrollOverWidth = the stageRight - the stageLeft - 4
end
--///////////////////////////////////////////////////////////////////////--
on mouseWithin me
pointClicked = the mouseLoc -- get the mouse position
currentLineNum = pointToLine(sprite(pMySprite), pointClicked) -- the exact lineNum that the mouse is over
if currentLineNum <> pLineNum then
resetColor(me, #oneLine) -- reset the previousLine rolled over to its origional color
pLineNum = currentLineNum -- set your new lineNum that the mouse is over
if pMouseState = #down then -- if the mouse is down then do the down rollover on other links
changeColor(me, #down)
else
changeColor(me, #over) -- change the color of that ne lineNum
end if
end if
PASS
end
--///////////////////////////////////////////////////////////////////////--
on mouseLeave me
resetColor(me, #oneLine) -- reset the color of the text
set pLineNum = 900 -- reset lineNum to an outrageous number so it will never be the currentLinNum
sprite(pMyRollOver).visible = FALSE -- hide the rollover
PASS
end
--///////////////////////////////////////////////////////////////////////--
on mouseDown me
changeColor(me, #down) -- set the text to the down color
set pMouseState = #down -- sets the state of the mouseButton to down
PASS
end
--///////////////////////////////////////////////////////////////////////--
on mouseUp me
changeColor(me, #over) -- set the text to the over color
set pMouseState = #up -- sets the state of the mouseButton to up
PASS
end
--///////////////////////////////////////////////////////////////////////--
on mouseUpOutside me
changeColor(me, #outside) -- set the text to the over color
set pMouseState = #up -- sets the state of the mouseButton to up
PASS
end
--///////////////////////////////////////////////////////////////////////--
on resetColor me, state
-- #all will reset the text to its default color
if state = #all then
repeat with i = 1 to member(pMyMemberName).line.count
member(pMyMemberName).line[i].foreColor = pMyNaturalColor
end repeat
end if
-- #oneline will change only that lineNum to the origional color
if state = #oneLine then
member(pMyMemberName).line[pLineNum].foreColor = pMyNaturalColor
end if
end
--///////////////////////////////////////////////////////////////////////--
on changeColor me, state
if pLineNum = 1 then -- omit the first line rollOver since it is the tittle of the menu
sprite(pMyRollOver).visible = FALSE -- hide the rollover
nothing -- this is specific for my instance so it can be deleted for other uses
else
if state = #over then
member(pMyMemberName).line[pLineNum].foreColor = pMyOverColor -- change the text to its over color
end if
if state = #down then
member(pMyMemberName).line[pLineNum].foreColor = pMyDownColor -- change the text to its down color
end if
if state = #outside then
exit -- of you do not exit then the doSolidRollover will return a error sonce you are not on a line
end if
doSolidRollover -- do the solid imageSizing to create a two stage rollOver
end if
end
--///////////////////////////////////////////////////////////////////////--
on doSolidRollover me
if pMyLineList[pLineNum] <> 0 then -- does this Line wrap???
n_LineHeight = pMyLineList[pLineNum] -- if wraped then add the wrapAmount from offSetList to set the lineHeight
else
n_LineHeight = 1 -- the lineHeight is normal
end if
-- establish the locV if the rollOver + a pixle offSet to help positin it the middle of the text field
set thisTopLoc = (pMyTopPos + (pMyOffSetList[pLineNum] + 4))
-- check the current with and if it is already set then do not resize it again
if sprite(pMyRollOver).width = pMyrollOverWidth then
nothing
else
sprite(pMyRollOver).width = pMyrollOverWidth
end if
sprite(pMyRollOver).visible = TRUE -- show the rollover
sprite(pMyRollOver).height = pFixedLineHeight * n_LineHeight -- sets the rollOver height
sprite(pMyRollOver).loc = point(2, thisTopLoc) -- position the rollover in the right point()
updateStage
end
--///////////////////////////////////////////////////////////////////////--
on wordWrapWorkAround me
pMyOffSetList = [:] -- contains the locV of the line top loc's
thisList = [:] -- a list containing values that state it wraps or not
lineOffset = 0 -- assume there is no line offset
repeat with i = 1 to member(pMyMemberName).line.count
if i = 1 then -- since the begining is one we say it is one!
firstLetterNum = 1 -- well it is usless to count the total and then subtract that by the total - 1 since we know it is 1
else
firstLetterNum = firstLetterNum + (member(pMyMemberName).line[i - 1].char.count + 1) --the first letter of the nextLine is 1 + the length(preveiousLine)
end if
lastLetterNum = firstLetterNum + (member(pMyMemberName).line[i].char.count - 1) -- the last letter is the fist letter + length(currentLine - 1)
firstCharLoc = getAt(charPosToLoc(member(pMyMemberName), firstLetterNum) ,2) -- get the LocV of the first character in the line[i]
lastCharLoc = getAt(charPosToLoc(member(pMyMemberName), lastLetterNum) ,2) -- get the LocV of the second character in the line[i]
if firstCharLoc < lastCharLoc then -- meaning that the first and last characters are not on the same line
set nLinesWraped = (lastCharLoc - firstCharLoc + pFixedLineHeight)/pFixedLineHeight -- divide the difference in the lines by the fixedLineHeight to find out how many lines it was wraped onto
addProp(thisList, i, nLinesWraped) -- add the amount of lines wraped to list pMyLineList
lineOffset = lineOffset + nLinesWraped -- keep a tally of the offset amount
else
addProp(thisList, i, 0) -- if there is no wrap 0 is the value
end if
addProp(pMyOffSetList, i, (firstCharLoc - pFixedLineHeight)) -- seperate list to keep the offSett amounts
end repeat
return thisList
end
--///////////////////////////////////////////////////////////////////////--
on getPropertyDescriptionList
return [¬
#pMyRollOver: [#default: 5, #format:#integer, #comment:"Set rollOver pixel channel:>"],¬
#pMyOverColor: [#default: 5, #format:#integer, #comment:"Text Over Color:>"],¬
#pMyDownColor: [#default: 15, #format:#integer, #comment:"Text Down Color:>"],¬
#pMyNaturalColor: [#default: 25, #format:#integer, #comment:"Text Default Color:>"]]
end
--///////////////////////////////////////////////////////////////////////--
on getBehaviorDescription
return "What the behavior does:" & RETURN & RETURN & "Turns a TEXT field sprite into a rollover menu."¬
& RETURN & RETURN & RETURN & "How to use:" & RETURN & RETURN & ¬
"1. A 1 pixel dots of any color must be on/off the stage." & RETURN & RETURN & ¬
"2. Drag and drop this behavior on to the text sprite that should act as the menu." & RETURN & RETURN &¬
"3. Select color values from 0 to 256 for the rollOver downState and the rearImageOver color." & RETURN & RETURN ¬
"If you wish to link to other pages refine your linking according to pLineNum for example if you create a property list.....myLinks[1:yourLink, 2:thatLink]." & RETURN & RETURN & RETURN & ¬
"Author: Markus Steinwender" & RETURN & RETURN & ¬
"Created: 6.12.00" & RETURN & RETURN
end
Contact
MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA