I recently did a similar thing.  I'll just post the code here and you 
can use if you want.

Some basic speed ups incude:
- Calculating the ColorRollOver and ColorNormal once at beginSprite
- Doing everything on exitFrame instead of "on mouseWithin"
- Optimization of remember which line the mouse is over, and if the 
mouse continues
    to be over the same line, don't do anything
- To turn color off, turn the whole member's color
-  This will work on a member with any number of lines

Enjoy,

Irv

PS:  the "goMenu" is an object that I needed to notify if something 
was chosen, you can do whatever you need to do instead ...


global goMenu

property pMember
property pfOver
property spriteNum
property pLastLineOver
property pColorRollover
property pColorNormal

on beginSprite me
   pMember = sprite(spriteNum).member
   pfOver = FALSE
   pColorRollover = rgb(199, 0, 42)
   pColorNormal = rgb(255, 255, 255)
   pLastLineOver = 0
end

on mHiliteLine me, lineNum, symOnOrOff
   if symOnOrOff = #on then
     if lineNum> 0 then
       pMember.line[lineNum].color  = pColorRollover
     end if
   else
     --if lineNum> 0 then
     pMember.color = pColorNormal
     --end if
   end if
end


on mouseUp me
   theFullText = pMember.text
   theLine = line pLastLineOver of theFullText
   goMenu.mHitLine(pLastLineOver, theLine)    -- do whatever you need to do here
end

on mouseEnter me
   sprite(spriteNum).cursor = 280
   pfOver = TRUE
end

on mouseLeave me
   pfOver = FALSE
   me.mHiliteLine(pLastLineOver, #off)
   sprite(spriteNum).cursor = -1
   pLastLineOver = 0
end



on exitFrame me
   if not(pfOver) then
     return
   end if

   -- hilight the appropriate line
   currentLineOver = pointToLine(sprite spriteNum, the mouseLoc)
   --put "Currently over line:" && currentLineOver
   if currentLineOver = pLastLineOver then
     return -- nothing to do
   end if

   if pLastLineOver > 0 then
     me.mHiliteLine(pLastLineOver, #off)
   end if

   pLastLineOver = currentLineOver
   me.mHiliteLine(pLastLineOver, #on)

end

on endSprite me
   member(pMember).text = " "
end


At 3:03 PM -0400 4/10/02, Carol Mahaffy wrote:
>hey list --
>i have a problem. i am trying to limit the number of graphic cast members
>that i have for navigation. I was attempting to create 1 text cast member
>with return delimited lines. Then using mouseWithin i get the line loc and
>swap my colors ect. I have tried this before but had to abandon because it
>seemed as if when you are using mouseWithin it slow the rest of the
>animations down at the same time. I am including the code. Can someone guide
>me on the "right/better" way of accomplishing this? much thanks

-- 

Lingo / Director / Shockwave development for all occasions. 
          
   (Home-made Lingo cooked up fresh every day just for you.)
[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to