Scaling dynamic text in AS3

June 24th, 2008

Recently I’ve had the need to scale a dynamic text field which was fed by XML. Readability after scaling was not important, but it did have to look good (it’s for a full Flash site). However, scaling the MovieClip that the text field was in would cause some pretty chaotic behavior with the text — the text would try to scale with its parent but in doing so would shift around spastically until the parent MC settled into a new scale. This was unacceptable.

A quick google didn’t yield anything relevant, so I was left to my own devices. I remembered being able to draw pixels to a BitmapData object while writing my game in order to improve performance, so I figured I’d see if I could just copy the pixels from the text field and “bake” it into a bitmap.

Turns out you can. In fact, Adobe had already done this in the help files and it’s actually extremely easy. Check it out:

var tf:TextField = new TextField();
tf.text = "bitmap text";

var myBitmapData:BitmapData = new BitmapData(80, 20);
myBitmapData.draw(tf);
var bmp:Bitmap = new Bitmap(myBitmapData);
this.addChild(bmp);

No sweat right? Anyway, since I didn’t find any help on this anywhere else (granted, I didn’t look very hard) I thought I’d share this little adventure of mine. Hope it’s helpful.

[view] :: [source]

Introducing: endlessPages

June 23rd, 2008

I’m not sure who came up with the idea first, but the crazy kids at Humanized gave me the inspiration to try this out for myself with jQuery. You can read their rationale for it, but the basic concept is that the “Next page” nav links are pretty ridiculous now considering how easy it is to dynamically load new content with ajax.

Now when you scroll down to view more content, it just loads it up automatically, giving the illusion of endless scrolling and a page of seemingly infinite length.

View the example page.

Also. I’ve updated autoScroll, fixing some stuff. You know how I said I’d release early and often? Turns out that doesn’t work well with me. I get lost in the code and after I finish and upload it, I completely forget to do anything else with it, such as adding a DocType to the page. Heh, yeah, not gonna do that anymore.

Quick suggestion: combining endless pages with my autoscroll script would make the page browsing experience completely seamless and effortless. Try it!

Introducing: autoScroll

June 17th, 2008

AutoScroll is a quick prototypage to see how well this alternative to the scrollbar would work. There’s an invisible scroll area at the very top and bottom of the page. When the user hovers their mouse over one of the areas it scrolls the page in that direction. Faster scrolling is achieved by moving the mouse deeper into the area.

View the example page.

Introducing: Cold Constructs

June 17th, 2008

Welcome to my new digital realm, fresh from the tubes. Not a whole lot here at the moment but I have quite a few projects in the works and will be releasing early and often (or whatever those kids are saying these days).

Cold Constructs is, as you might have guessed by the subtitle up there, a place where I publish stuff I’ve made. What kind of stuff, you might ask. Scripts, plugins, games and other creative works, among many other kinds of things — eventually, anyway.

Most things here are geared towards one central goal: making computers better as best I can. I’ll provide new interface designs, largely as Flash projects, or try to make interesting new game designs (exclusively in Flash).

But this is also my personal site where I like to share my work and get feedback on it. So please don’t be shy with the comment form, and I will always enjoy an email with constructive criticism as well.

Thanks for stopping by, I hope you dig the place.