This content has been marked as final. Show 7 replies
> So if I found a free sprite slot, how do I turn it into a text sprite, and set
> the font/point size etc... ?
-- first you create a #text member with:
tTextMember = _movie.newMember(#text)
-- and set its properties like:
tTextMember.font = "Arial"
tTextMember.fontSize = 36
-- whatever other props:
tTextMember.text = "test"
tTextMember.color = color(255, 0, 0)
-- display it on the stage:
sprite(n).member = tTextMember
thanks that works great.
Just one new problem now...
How do I determine the width of the character or string I am printing in pixels ?
So that I can correctly center them inside my text boxes ?
The help documentation doesn't offer any clues that I can find.
> How do I determine the width of the character or string I am printing
> in pixels ?
> So that I can correctly center them inside my text boxes ?
> The help documentation doesn't offer any clues that I can find.
Would changing its alignment help?
You have cross-posted this question to the Director Online forum, and perhaps also elsewhere. Once you have a satisfactory answer to your question, please collate all replies and post them to all the places where you asked the question, so that others with a similar question can find the solution.
yep the answer to the first part was already poseted in both forums. I'll continue to do do this, thanks for the tip.
for the second part... I had to use #center instead of "center" as it was a run-time created member text sprite.
But this moved my printed character about 200 or 300 pixels away from where it was supposed to be.
Probably because the text sprite co-ordinates and size do not match the size of the graphic sprite text box below it, so it doesnt know how to center it properly.
It would still be nice if there was a way to get the pixel width of a string, word or character that it is going to print.
> for the second part... I had to use #center instead of "center" as it
That's what I get for checking in the help file...
> It would still be nice if there was a way to get the pixel width of a
> string, word or character that it is going to print.
member("textMember").charPosToLoc(length(member("textMember").text) + 1))
thanks Andrew that did the trick..
the final line is..
charWid = tTextMember.charPosToLoc(length(tTextMember.text) + 1).locH