Embedding Fonts into Actionscript Only Project (AS3)

Embedding fonts has been a bane to me for some time, and I finally spent the time to find both the easiest and most comprehensive way to embed needed fonts into a SWF using AS3 only. As always, I try to keep the demos here as lightweight as possible, and I have tried to keep any code snippets I give free from external resources. In this case, there is a small exception, but it is only the exception of using one of the fonts installed on your own computer.

Basically, we need to understand a couple things about the nature of the embedded font in Actionscript. First, it must be assigned to a String in order to store all the character references. Next, you will quickly find that creating and implementing a TextFormat object to attach the font and styles to the different places in which it will be used is ideal. Finally, keep in mind that attaching several fonts to a single application can significantly increase the file size, so try to consolidate and style for variety as much as possible instead of selecting a boat load of different font faces.
Continue reading

Map Handling Take 3 – Hover Over Borders (AS3)

Well, at the risk of sensory overload today – it’s my blog after all – I decided to post one more version of my map handler. This one adds in the classic mouse hover scroll effect at the edges of the map. I did try to make it a bit more usable, though, by calculating the distance from the edge of the map and accelerating the movement appropriately. So, the closer to the edge you are, the faster the map scrolls. So, to recap, you can use the following methods to move:
Continue reading

Drag Viewport for Map Preview in AS3

So, a really quick update post here. Upon publishing my previous post, I received some great feedback from gamer friends who thought a good way to improve the interaction would be to allow for dragging the preview marker around to update the viewport in addition to simply clicking. After giving this some thought and suppressing some immediate concerns about the overhead calculations this might take, I have implemented this change and am interested in getting some feedback. Of course, all the other features (like clicking the preview and navigating the map using the A, S, D and W keys). Feedback welcome as always…
Continue reading