behavior to center text vertically
centering text vertically

  centering text vertically
> I've got (dynamic) text in a fixed text sprite that needs to be
> centered vertically.

property myMember
property myType
property myHeight

on beginSprite(me)
  myMember = sprite(me.spriteNum).member
  myType   = myMember.type
  myHeight = myMember.pageHeight

on centreText(me, newText)
  myMember.text = newText
  textBottom = (myMember.charPosToLoc(newText.char.count+1)).locV
  spaceAtTop = ((myHeight - textBottom) + myMember.topSpacing) / 2

  if spaceAtTop >= 0 then
    myMember.topSpacing = spaceAtTop
    -- The text is too long to show in full.  Change the font size
    -- or set myMember.boxType to #scroll...
    myMember.topSpacing = 0 -- Limit the damage as a stopgap
  end if
end centreText

on isOKToAttach(me, spriteType, spriteNumber)
  return sprite(spriteNumber).member.type = #text
end isOKToAttach



Home shock + cgi Bits 'n pieces Director Lingo ShockLets Contact