Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
LiveCD
Ripple Button-Alphamania
Relative Links
Drop File
Macromedia Flash 5 From Scratch
Start Menu(xml)
3D SpeedPort Xtra
Set Volume - Buddy API
Fade In and Out plus other commands
Menus like VB
 

 

 

Behavior Hilite Lines - Text and Field

Added on 5/9/2001

 

Compatibilities:
behavior D7 D8 D8_5 Mac PC Shockwave

This item has not yet been rated

Author: MediaMacros (website)

This fakes a line hilite (of the entire line) for a text and field member.

Download PC Source    Download Mac Source
property spriteNum
property pHiliteSprite
property pCurrentLine
property pLastScrollTop
property pWhatAction

on beginSprite me
  --set the current scrolltop
  pLastScrollTop = sprite(spriteNum).member.scrolltop
  --nothing currently selected
  pCurrentLine = 0
  --build tracklist
  me.makeRectAround()
end

on getPropertyDescriptionList me
  p = [:]
  p.addProp(#pHiliteSprite, [#format : #integer, #comment : "What sprite is the hilite shape in?", #default : the currentSpriteNum + 1])
  p.addProp(#pWhatAction, [#format : #symbol, #comment : "What action to trigger the rollover?", #default : #rollover, #range : [#rollover, #click]])
  return p
end

on mouseUp me
  if pWhatAction = #click then
    --get the line
    selectedLine = me.getLine()
    if selectedLine = pCurrentLine then
      --deselect
      pCurrentLine = 0
    else
      pCurrentLine = selectedLine
    end if
    me.makeRectAround()  
  end if
end

on getLine me
  if sprite(spriteNum).member.type = #text then
    return pointToLine(sprite spriteNum, the mouseLoc)
  else if sprite(spriteNum).member.type = #field then
      return locVToLinePos(sprite(spriteNum).member, the mouseV - sprite(spriteNum).member.scrolltop - sprite(spriteNum).top)
      end if
end

on getLineHeight me
  if sprite(spriteNum).member.type = #text then
    a1 = 0
    if pCurrentLine > 1 then
      a1 = linePosToLocV(sprite(spriteNum).member, pCurrentLine - 1)
    end if
    a2 = linePosToLocV(sprite(spriteNum).member, pCurrentLine)
    return (a2 - a1)
  else if sprite(spriteNum).member.type = #field then
    return sprite(spriteNum).member.lineheight    
  end if
end

on exitFrame me
  if pWhatAction = #click then
    --check to see if we have scrolled
    if pLastScrollTop <> sprite(spriteNum).member.scrolltop then
      pLastScrollTop = sprite(spriteNum).member.scrolltop
      me.makeRectAround()
    end if
  end if
end

on mouseEnter me
  if pWhatAction = #rollover then
    selectedLine = me.getLine()
    pCurrentLine = selectedLine
    me.makeRectAround()  
  end if
end

on mouseLeave me
  if pWhatAction = #rollover then
    pCurrentLine = 0
    me.makeRectAround()  
  end if
end

on mouseWithin me
  if pWhatAction = #rollover then
    selectedLine = me.getLine()
    if selectedLine <> pCurrentLine then
      pCurrentLine = selectedLine
      me.makeRectAround()
    end if
  end if
end

on makeRectAround me
  if pCurrentLine > 0 and pCurrentLine <= sprite(spriteNum).member.line.count then
    --get the height of the line
    lHeight = me.getLineHeight()
    --get the scrolltop
    myScrollTop = sprite(spriteNum).member.scrollTop
    myRectTop = sprite(spriteNum).top + (lHeight * (pCurrentLine - 1)) - myScrollTop
    myRectBottom = myRectTop + lHeight
    if myRectBottom >= sprite(spriteNum).bottom and myRectTop <= sprite(spriteNum).bottom then
      --cut short below
      myRectBottom = sprite(spriteNum).bottom
    else if myRectTop >= sprite(spriteNum).bottom then      
      --below the line      
      myRectTop = -1000
      myRectBottom = -1000
    else if myRectBottom <= sprite(spriteNum).top then
      --above the line
      myRectTop = -1000
      myRectBottom = -1000
    else if myRectTop <= sprite(spriteNum).top and myRectBottom >= sprite(spriteNum).top then
      --cut short
      myRectTop = sprite(spriteNum).top
    end if
    --set the rects
    myWidth = sprite(spriteNum).width
    sprite(pHiliteSprite).rect = rect( sprite(spriteNum).left, myRectTop, sprite(spriteNum).left + myWidth, myRectBottom)
    sprite(pHiliteSprite).rect = rect( sprite(spriteNum).left, myRectTop, sprite(spriteNum).right, myRectBottom)
  else
    sprite(pHiliteSprite).loc = point(-1000,-1000)
  end if
end

on getBehaviorDescription me
  return "Drop this on a text member and give it the number of a sprite with a QuickDraw member set to reverse ink. (In a higher channel than the text sprite)"
end

on getBehaviorTooltip me
  return "Drop this on a text member and give it the number of a sprite with a QuickDraw member set to reverse ink. (In a higher channel than the text sprite)"
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail