Flex bug + Peter DeHaan = workaround + wheels in motion

 

I know, I know—Flex post?! I have been “drinking the Koolaid” these past few months, but this post is for the greater good. I found a bug and it had me panicking for a few solid hours yesterday. I typically would’ve kept my cool, but with a deadline quickly approaching and the fact that I’m still somewhat new to Flex, it was time to sound the alarms.

First, what’s the bug? It occurs when using multiple item renderers with the List component and changing the dataProvider property. The List should recycle the currently used renderers and choose ones that apply to the new data. Instead, the List tries to use the previous renderers on the new content, regardless of whether they match the data.

I resorted to using some internal resources at Adobe and within minutes had a workaround and bug report, courtesy of Peter DeHaan. Simply, reset the itemRendererFunction each time you change the dataProvider property. I know it’s a bit redundant, but it works and is a temporary solution until the fix is in place. If you’re interested in following the bug, you can watch it on JIRA.

EventMap.mapListener bug (and fix!) in RobotLegs

 

This past week, I experienced a bug with RobotLegs where the EventMap.mapListener method would add the listener multiple times if called multiple times. Yesterday, I had some free time to dig a little deeper and managed to pinpoint the problematic code. It turns out the method didn’t check to see if the listener existed prior to adding to the array. This explains why a button click handler in my code would respond twice.

Thanks to the oh-so-wonderful GitHub, I was able to fork the repository, implement the fix, write a unit test to verify it’s safe, and find in the morning that it has been integrated into the actual RobotLegs repository—just like that. If you experienced the bug, be sure to pull the latest commit.

Now, if you’re not on GitHub, do yourself a favor and join today. In the few months I’ve been a member, I’ve met a handful of incredible developers and now feel compelled to share code when I can. Everyone benefits when you share what you know.

‘Undocumented feature’ in Rob Penner’s AS3 Signals

 

bug_feature

Last week, I started replacing events in DestroyFramework with Rob Penner’s AS3 Signals. They’re faster, shorter, and include a few methods that developers have been dying for. Unfortunately, the first implementation, into my new Group class, didn’t work. I was puzzled to say the least. After literally hours of testing and debugging, I discovered the culprit.

It turns out, the remove(listener) method lacks a check for listener existence in the listeners array. When the method is called, if the index of the listener returns -1, the array splices the first listener. I forked the Git repository and implemented the fix on the Signal, NativeSignal, and DeluxeSignal classes. And because a fix isn’t a fix without proper unit testing (says Joel Hooks), I added the unit tests as well.

Where to find the right fontName

 

To preface, I embed fonts using the Embed metatag and fontName parameter with an SWF as the source. If you’re unfamiliar with this method, it looks like this:

1
2
[Embed(source="assets/fonts.swf", fontName="Helvetica")]
protected static const HELVETICA:String;

This past week, I came across the same issue twice. Up until now, I only worked with fonts that used the fontName as it appears in Flash’s properties panel. Sure, this works for fonts with simple names, but when you start getting fancy, things get messy. I needed to embed Alternate Gothic No. 2 and Flash labeled it as “AlternateGothic” with “No2″ as the style. I set the fontName as “AlternateGothic No2″ and was presented with this familiar gem:

fontname_error

I get shivers each time I see it. After a few minutes of failed guess and check, I set out for a solution. I opened FontExplorer X and discovered that the font is labeled as “AlternateGothic-No2″.I gave it a shot and boom went the dynamite. From then on, I thought that would be the correct fontName—the font’s label in Font Explorer X.

fontname_fontexplorer

I was wrong. This week, I needed to embed Helvetica Neue Roman, which is labeled as “12 pt Helvetica* 55 Roman 05472″ in FontExplorer X—freaky, eh? I tried it out and the error returned. At first, I was bummed because I thought I had a foolproof solution. I was close, but no cigar. I opened Font Book to get a second opinion. Apparently, the font’s true name is “12 pt Helvetica* 55 Roman 05472″, which means FontExplorer X removes redundant whitespace, found in our example between “Roman” and “05472.” I tried it out and, sweet sassy molassy, it worked.

fontname_fontbook

From now on, I’ll consult Font Book when embedding a new font.

DIY steadycam for under $20

 

Yesterday, I set out to revisit my building days with a DIY project. After finding my high school films, I felt compelled to utilize the video aspect of my Canon 5D MKII. It’s brilliant for capturing HD video, but if your lens doesn’t have image stabilization and your grip isn’t rock solid, it might look like you’re always shooting during an earthquake.

A while back, I stumbled upon Johnny Chung Lee’s tutorial on building a $14 steadycam, “The Poor Man’s Steadicam.”  A father/son trip to Home Depot and 20 minutes later, I had a steadycam that worked beautifully. I did come across an issue or two.

If you ever plan to use your camera/camcorder off the steadycam, a quick release system is a necessity. For a solid and reliable quick release, look no further than the Manfrotto 323 RC2 System. At just under $30, it defeats the claim of a steadycam under $20, but I’d gladly pay extra to know my camera is safe, sitting on a reliable system. The standard tripod thread size is 3/8″, but the 323 RC2 comes with a 1/4″ reducer bushing, making it compatible with Lee’s specs.

I’m happy with the steadycam for now, but I certainly see a few mods in the near future. Top on the list is rubber grips. Holding the steadycam for a minute leaves your hands smelling like galvanized steel for the rest of the day. And if you have any plans to shoot in cold weather, these pipes will freeze faster than a Jack Rabbit on a hot date.

This project has gotten me back into the building spirit and it was just what I needed to fill my free time away from the computer.

steadicam_0

steadicam_1

Free Gems: smcFanControl

 

smcFanControl

I can’t believe I haven’t posted this free gem yet, especially considering summer’s end is near. smcFanControl is an oldie, but a lap-saving goodie. It lets you manually set the minimum RPM of your computer’s fans, in case your palms are frying and OS X doesn’t smell the burning flesh.

iPhone 3.0.1 update fixes SMS vulnerability

 

iPhone SMS vulnerability

It’s been a scary past few days. First, I start getting nonsense texts from random international numbers. Then, the next day I see this report by Forbes, describing a security vulnerability in iPhones, which is based around these exact texts. I immediately turn off my iPhone, as suggested—since it’s new, I’m still carrying around my ancient 1st generation LG chocolate. Last night, I turned my iPhone back on only to wake up to a handful of these texts this morning.

Thankfully, the issue has been addressed before any harm was done. If you connect your iPhone, you’ll be prompted with the 3.0.1 update that takes care of everything. Part of me felt foolish, as if this were some sort of Y2K hub-bub, but there’s no reason to risk it.

Mini DisplayPort to HDMI adapter… w/ audio!

 

Mini DisplayPort to HDMI adapter

Throughout college, I saved money where I could by opting out of amenities like air conditioning and cable TV. I got around the lack of these with an abundance of Hawaiian Breeze fans and a DVI-to-RCA adapter. Now that I’m out of college, I have a bit more leniency with these comforts. I did opt for central A/C in my new apartment, but I don’t think I’ll be going for cable TV just yet.

A few months ago, I took the plunge and got a 40″ Sony Bravia HDTV—my boy, James Hall, pointed me to a steal on Slick Deals. Anyone with an HDTV knows that input through RCA doesn’t benefit whatever you’re watching, so I’ve been using a DVI-to-HDMI adapter I got from Newegg. It’s really great so far, but the only issue is audio. Since it comes from the laptop, the experience is the equivalent of watching Transformers on IMAX 3D, but using one of those corded speakers from a drive-in theater.

Now emerges Kanex, a company that’s developed a Mini DisplayPort adapter that outputs to HDMI with audio—and it works! Gizmodo wrote a review of the adapter, and by the looks of it, this device isn’t some MadCatz waste of hard-earned money. I’ll be picking one up as soon as I get back from SF—along with the long-awaited Cablox.

Fixing an enlarged iTunes window

 

Fixing iTunes window

Since working at Adobe, I’ve been using a 30″ Apple display as my primary screen. It’s all well and good while I’m there, but when I get to the hotel, some apps forget to scale down their windows. With the resize handle barely out of reach, it kills me, even if I don’t use any of the now hidden controls—it’s the principal of the matter. iTunes is my biggest concern—I use it daily and if the window is too big, it throws off my game.

After a quick tweet, the great people on Twitter came to the rescue once again with an extremely simple fix: option-click the maximize (green) button. I’m in love with little hotkeys/clicks like this, but maximizing from the condensed window should really readjust itself.

Thanks @cm2 and @flippy10