-
[AS3] Animated Text Effect Problem
Here's one for y'all.
In the game I'm creating I'm trying to acheive a animated typing effect. I've written a class for this purpose.
It works fine but there is one problem. As you know, text renderers try to fill as much of the current line as possible before starting on the next line.
This is what visibly happens in my case. To illustrate the problem go to here:
http://www.fatal-exception.co.uk/test/index.htm
When you open the example click the blue box to see the example. You can keep clicking or pressing keys on the stage to show the issue.
Has anyone faced this issue and/or know/read about a solution to this sort of issue?
Thanks.
Last edited by Cortana; 09-09-2008 at 08:02 AM.
now known as dVyper
-
One somewhat hacky option is to detect the background color and just type out all the text at the beginning, at the same color as the background, then instead of typing each letter, just set the color of each letter to black as the text is typed.
An alternate method could be to, at the very beginning, type all of the text and save all of the line offsets. Then as you're typing, if you get to a character that's supposed to be on the next line, add spaces to the text field until it jumps down to the next line. Then after the word is complete, you can go back and reset the text without the spaces, if you want. Or just leave them. Or replace them all at the end. Whatever.
I'd like to think that there are better options, but these are the ones that came to mind.
-
Senior Member
About the first method of WesIsGood, instead of using the background color, just use an alpha 0 color.
This is how I would do : When you add a new letter, if it's the firs letter of a word, add the whole word. Without rendering you can know if text has gone one line below (just use the textHeight property). If there is a carriage return for the whole word, then you add a carriage return before adding this new letter.
-
Can you set alpha values for text color?
-
Thanks for the suggestions guys!
@Wes
As far as I know you can only change the alpha of text in a TextField if that TextField is in a MovieClip and you change the alpha of the MovieClip.
-
Senior Member
You could use second textfield (not visible on stage) and add full words into that. Once it goes on next line you can add carriage return into textfield you use to type letters on.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|