Recently, I decided to throw something up onjoshtynjala.com. Nothing fancy or special. Just thought I’d mention that I’m a Flash developer and put a couple links pointing to the blog here. A simple SWF displays the recent postings from the various blogs to which I contribute. Part of the project’s goal was to display the posts in an interesting way, so I created a couple of custom TextField subclasses that manipulate the text as they display it.
EFFECT #1: TYPINGTEXTFIELD
This one is obvious. When the text
property changes, the TextField
clears and adds one letter at a time to simulate typing. A simple blinking cursor may be displayed to give it a command line sort of appearance.
EFFECT #2: DECRYPTINGTEXTFIELD
Hollywood doesn’t understand computers. That said, it’s always cool to see the combination for a safe with an electronic lock get cracked character by character. The DecryptingTextField
displays a set of random letters that cover the full length of the text
property. One by one, the proper characters are displayed.
A couple things to note on this one. If you’re going turn on word-wrapping for a DecryptingTextField, you should set the keepSpaces
property to true. This will minimize ugly changing line breaks by always displaying spaces when the randomizer encounters a space in the original text. Additionally, to further improve the aesthetics, you might want to consider using a mono-spaced font like Courier or Consolas so that the characters stay in the same location every time a new random character is displayed. It doesn’t look bad on a single line, but it’s more noticeable when you have multiple lines.
Interested in how I combined my RSS feeds? I didn’t do it directly in ActionScript. Instead, I took advantage of Yahoo! Pipes to create a combined feed for this blog and any posts that are specifically authored by me at theYahoo! Flash Blog.
Source code is linked above under each demo. They’re under the terms of anMIT-style license so you may include them in both open source and commercial projects.
原文:http://www.zeuslabs.us/2008/01/17/source-code-for-custom-textfields-with-cool-effects/