A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [AS3] Animated Text Effect Problem

  1. #1
    Developer
    Join Date
    Apr 2007
    Location
    UK
    Posts
    324

    [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

  2. #2
    Senior Member
    Join Date
    Mar 2008
    Posts
    301
    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.

  3. #3
    Senior Member Sietjp's Avatar
    Join Date
    Jan 2005
    Location
    Paris, France
    Posts
    711
    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.

  4. #4
    Senior Member
    Join Date
    Mar 2008
    Posts
    301
    Can you set alpha values for text color?

  5. #5
    Developer
    Join Date
    Apr 2007
    Location
    UK
    Posts
    324
    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.
    now known as dVyper

  6. #6
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center