Try this parent script. Call it after you've dragged the field to the stage.
----------------------
property pWidth -- the width of the help-text field
property pHelptext
property pHeight -- the height of the help-text field
property pSprite -- the spriteNum
property pHelpSprite -- the spriteNum of the help-text field
property pHelpNam -- the name of the help-text field
property pStageWidth -- the width of the stage
property pStageHeight -- the height of the stage
on new me, spr
pSprite = spr
pHelpNam = sprite(pSprite).member
pWidth = pHelpNam.Width
pHeight = pHelpNam.Height
pHelpNam.text = ""
return me
end
-- usage : gTxtObj.mAdjust()
on mAdjust me
theText = pHelpNam.text
member(pHelpNam).rect = cropIt(me, theText)
end
on cropIt me, theString
-- init
bestRect = pHelpNam.rect
theLine = theString.lines.count
theWidth = 0
checkedChars = 0
repeat while theLine
endOfLine = offset (RETURN, theString)
if not endOfLIne then
endOfLine = (the number of chars of theString) + 1
pHelpNam.text = pHelpNam.text
end if
checkedChars = checkedChars + endOfLine
endPoint = charPosToLoc (pHelpNam, checkedChars)
lineWidth = endPoint[1]
if lineWidth > theWidth then
theWidth = lineWidth
end if
delete char 1 to endOfLine of theString
theLine = theLine - 1
end repeat
lastChar = pHelpNam.char.count
lastCharLoc = charPosToLoc (pHelpNam, lastChar)
theHeight = lastCharLoc[2]
bestRect[3] = theWidth + 1
bestRect[4] = theHeight + 1
return bestRect
end
----------------------
regards
John
> Hello all,
>
> I've been working on a project that requires the creation of
> field members
> on the fly, but when they are placed on the stage the come in
> at a fixed
> width. I can't use text members as they will need to be edited.
>
> Is there any way of getting them to be no wider than the
> words (1 word per
> field) that they contain ?? I have tried setting the sprite
> width but this
> is not reflected on the stage ?
>
> Any suggestion would be greatly appreciated.
>
> [EMAIL PROTECTED]
> ______________________________________________________________
> ___________
> Get Your Private, Free E-mail from MSN Hotmail at
http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/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!]
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/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!]