Flash HTML Textfields – Kick it Old-School

Most professional-grade fonts don't register the bold & italic outlines with the same postscript name. For example, "Berthold Akzidenz Grotesk BE", "Berthold Akzidenz Grotesk BE Bold", "Berthold Akzidenz Grotesk BE Italic" So to get these to work, you've got to either use stylesheets or explicitly set the text to use the correct face.

I updated my portfolio recently, and I didn't have time to implement a new shell (unfortunately) or code the whole thing over (as much fun as that is). Nor did I feel like tracking down a bug that kept me from publishing the swf to target anything above Flash Player version 6. Yeah, 6.

There wasn't any StyleSheets class back then. Add to this my crazy text-layout-in-a-circle routine, and adding bold, italic, and link support is an absolute nightmare. But I did it, and now I can show you how.

1st, parse the html as xml and replace the <b> and <i> tags with <font face=""> expressions that will actually target the correct font. I actually wrote a class that lets you map any tag to any other tag.

Next, stick all the html in a temporary textfield and map out where all the TextFormat changes occur. I wrote another class that can compare two TextFormats for equivalence.

My text-in-a-circle code adds words one-at-a-time, effectively creating a custom word-wrap routine. However, I had trouble when I attempted to use a single TextField, so each row uses a separate one. If you're up to something like this, you have to keep track of how many characters you've already used in previous fields. At first, I was getting lots of off-by-one errors and found a carriage-return character (character code 13) kept slipping into my input. Funny, I didn't put that there...

Flash also doesn't do a great job rendering things like <b>word</b> <b>second word</b>. It likes to collapse that and the space disappears. I swapped the spaces for non-breaking-spaces (&nbsp;) Feels dirty, but gets the job done.

And remember all those posts about entity problems with HTML coming from XML? The big reason for this undertaking was so I could support links in my portfolio project descriptions. When I linked to google maps, guess what happened to the query parameter ampersands in the href ...

The code is so crufty, even I won't post it. Drop me a line and I'll send you a private peek.

Helpful Automator Workflows for Developers

I love OS X. For me, it's the ideal development platform. I primarily build web applications that run on the LAMP stack, so having a POSIX compliant UNIX like OS for my daily driver is extremely convenient. My development environment works just like the environments I deploy to, so I don't have to worry very much about platform inconsistencies. OS X is the perfect balance of elegance and power. I only wish Finder didn't suck so hard.

There are some actions I need to perform on files on a regular basis that are not supported in Finder. For example, recursively deleting files in a tree of directories, but leaving the directory structure intact. I have a code generation tool that scaffolds out a boatload of PHP classes based on MySQL database. During heavy development, I need to blow away the files on a regular basis without deleting the output directories. Finder simply cannot do this. Luckily Apple has provided a way to add Automator actions to the context menu in Finder. I put together a simple workflow to recursively delete files in a tree of folders, here is is for your convenience:

DeleteFolderContents.zip - MD5: 5d0ad832e9e998dbefd70d49f2a07b52

Unzip, and copy the workflow file to Library/Workflow/Applications/Finder/ in your home directory. If all has gone well, you should have a new option in the context menu when you right-click a folder in Finder:

Automator Workflow As Finder Plugin

Automator Workflow As Finder Plugin

Another Finder deficiency that was bugging Jon recently is the inability to copy the filesystem path of a folder in Finder to your clipboard. I put together a little workflow that does just that:

CopyPathToClipboard.zip - MD5: b64558cf3afb7aecdec63faccb5986ba

Follow the same steps outlined above to copy the workflow to the proper location.

Note that these workflows are compatible with OS X version 10.5, and will not run in Automator on 10.4 or previous systems.

, , ,

SEO Presentation for NCSU Web Developer Group

Jon and I delivered a presentation about SEO to the NCSU Web Developer Group this afternoon. If you were in attendance, thanks very much for coming to see us, we hope you found it informative. We talked about a lot of useful online resources during the presentation, all of the links are in the slide deck that we've posted for your convenience. You can download a PDF of the slides here, or view them on SlideShare

Please feel free to post comments and questions here.