Latest Entries

Fixing setDefaultAnnotationNamespace Error With Doctrine ODM and MongoDB

If you recently attempted to set up a project to use MongoDB and Doctrine ODM by following the instructions at, you probably ran into this error coming from your bootstrap file:

PHP Fatal error:  Call to undefined method Doctrine\Common\Annotations\AnnotationReader::setDefaultAnnotationNamespace()

I just spent more time than I would like to admit trying solve this problem, so I figured I would try to save someone else from the same issue.  The problem is that in the latest version of AnnotationReader, the setDefaultAnnotationNamespace was removed.  The solution is to replace the following lines:

$reader = new \Doctrine\Common\Annotations\AnnotationReader();
$config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/Documents'));

with something like this:

$annotationDriver = $config->newDefaultAnnotationDriver(array(__DIR__ . '/Documents'));


You’re welcome.

Add a download link to your WordPress 3 post

I’ve had a few people ask me how to add a download links to WordPress posts so I figured I’d do a post about it.  It’s quite easy, so here we go.

STEP 1: Click the “Upload/Insert” link above your post.

STEP 2: Select the file that you want people to be able to download by clicking the “Select Files” button

STEP 3: After the file has finished uploading, change the title and description fields to what you want the link text to say.  For example, I used “Click Here to download the test PDF.”

STEP 4: Click the “Insert into Post” button

STEP 5: You should see a link like the one below.  That’s it!

Click Here to download the test PDF

AIR for Android and Wake Lock with Keyguard

I have an application where I want to prevent sleeping, but I still want the user to be able to lock the screen using the power button.  The conventional wisdom is to do something like the following:

protected function view1_addedToStageHandler(event:Event):void


    NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;

    stage.addEventListener(Event.DEACTIVATE, releaseWakeLock);


protected function releaseWakeLock(event:Event):void{

    NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.NORMAL;


This, however, does not work.  The problem seems to be that the Android OS receives the sleep event before the AIR application does, and therefore when the user presses the power button again, the screen is not locked.  The solution, fortunately, is simple – just don’t enable the DISABLE_KEYGUARD permission in the android manifest.  The comments from Adobe say to toggle both DISABLE_KEYGUARD and WAKE_LOCK together, but everything seems to work as I would expect with just WAKE_LOCK.

Flash 10.1 on the Sprint EVO 4G… Sort of

So I bought the new Sprint EVO on Friday.  Yep, I am officially an Android fanboy now.  Coming from my previous phone, the iPhone 3G, i was a little nervous about features, interface, etc. but overall, I am quite pleased so far.  It’s very fast, the camera is great, there are lots of little bells and whistles, and most of the apps that I used regularly on the iPhone are also available in the Android market.

One feature that I wasn’t expecting was decent Flash support.  I read a lot of blogs and reviews most said something like “Sprint EVO, yada yada, Android 2.1, yada yada, no Flash.”  So, when I got my shiny new EVO and started traversing the Intertubes, the first thing I noticed was “hey, there’s an animation where i normally see the little sad Lego block!”  My first thought was, that some ad company had created some animated Gif ads for mobile, but after a little more observation I realized, nope – it’s Flash!  So after 20 to 30 minutes of visiting every Flash site I could think of,  I came across this:, whaaaaaaa!  (Borat impression)  I decided this couldn’t be so I whipped out Flex Builder and created my own swf making use of the system.Capabilities class.  Here is what I found:

Hmmm, same version.  Well, only one way to see if we’re really dealing with a Flash 10 player here – try out some content that requires it.  My 3D carousel app is a perfect candidate.  Here is the result:

As you can see, it’s totally broken.  So the obvious conclusion is that this player is some version of Flash 9 that is incorrectly reported by the Capabilities class.  A little disappointing, but still, I’m just happy to have Flash back on my mobile.  Now I’m even more looking forward to Froyo and 10.1

Flash 3D Carousel with Z Sorting and Depth of Field

The 3D features added to ActionScript along with Flash player 10 make it quite easy to implement the famous 3D carousel. I remember quite well the not-so-distant past when faking this effect using scales and x-y coordinates was the only option. Click on the picture to see it in action.  A link to the source is below.

3D Carousel

If you are implementing your own, here are a few things to keep in mind.

1. Center your projection

If your swf auto-sizes to fill the browser window, your projection center (kind of like the camera position) might not be where you want it.  Move it using the “transform.perspectiveProjection” property.

2. Sort your Zs

Even though Flash handles the perspective projection for you, it does not draw objects order by Z depth.  Objects are always rendered in the order they were added to the display list.  In other words, and object farther away from the camera could render on top of a object that is closer.  The way to fix this is to reorder the items in the display list according to their Z coordinates.

3. Use the Matrix3D and Vector3D classes

You can do a lot of complicated trigonometry if you enjoy that sort of thing, but the built-in rotation and transformation functions of these classes make things easy.


Reading Twitter From Flash Without a Proxy Script!

As you may be aware, the site has a crossdomain policy file that restricts direct loading of API data from Flash players on remote sites.  The common solution to this problem is to put a PHP proxy script on your server that reads from Twitter while your SWF reads data from the proxy.  It’s effective, but not everybody has the ability to slap a proxy script on the ol’ server whenever they feel like it.  So, after toiling in the laboratory for a little while, I have come up with this.  Behold!  The proxy-free Flash twitter module.

Get yourself a Flash Player!

I’m not going to get into the details at this point, but I’ll give you a hint as to how it’s done.  Two words: “Javascript Injection”  Ping me  in the comments if you would like to know more.

Thoughts on Steve’s Thoughts on Flash

If you haven’t already seen it, yesterday His Steveness published a note on what he thinks about Adobe Flash.  I wish Steve would just man up and say, “I don’t like Flash and it’s my device so I’ll do what I want with it,” but instead we keep getting these little statements where he twists the facts in an effort to Jedi-mind-trick us into thinking it’s for our own good.  Here are my thoughts on what he had to say.

1. Open

Adobe Flash is most certainly an open format.  See the links below.  The SWF format is open, they provide and maintain an open source SDK that you can use to build flash apps, and they allow third party companies to create IDEs for developing Flash apps.  If you had enough time and resources you could develop an open source Flash player plug in for browsers.

Furthermore, claiming that the iPhone is an open platform just because it includes an application (Safari) that is capable of reading and rendering data (HTML5) that is formatted using an open standard is ridiculous.  Using this logic, when Flash is able to render HTML5, it will also become an open platform.  You could also call the Wii an open platform simply because it has a browser.

One last note, the “open video format” that Apple champions, H.264, is not at all open.  If Apple is so proud of their “openness”, why not support HTML5 and Ogg?

2. Full Web

Steve uses some twisted logic here.  Just because Youtube has 40% of the videos that exist on the web, and Youtube supports HTML 5, that does not mean that 40% of the web has already converted to HTML 5.  Also, Flash is used for a lot more that just video; games, photo galleries, news tickers, data visualization, and audio players just to name a few.

3. Three in one on this one.  I’ll address them separately:


In version 9.0.115 of the Flash player there was a buffer overrun bug that could be exploited to remotely execute code.  Adobe fixed this with an update in April of 2008.  Firefox has had many such vulnerabilities before and since then, but nobody advocates against its use… Well, not yet, but maybe Apple will before long.


According to Steve: “Flash is the number one reason Macs crash”.  Now, I’m no Linus Torvalds, but I do have a degree in computer science and I’ve taken a few classes on operating systems.  From this, my understanding is that if a user-space application can crash your whole OS, you’re doing something wrong.  This is one of thing Apple likes to mock Microsoft about.


From what I have read, part of the reason Flash support has suffered on the Mac is a lack of support from Apple.  Until recently, the Flash player has been forced to use the QuickDraw and Quartz 2D APIs for rendering, neither of which is really intended for animation.  Also, until literally this week, the Flash player has not had access to hardware accelerated H.264 decoding.

Oh, and regarding Steve’s claim about never seeing Flash perform on a mobile – maybe he should have used his beloved HTML 5 to view some of these videos on Youtube:

One other point that I would like to make is that no matter what the language/platform/technology, you cannot totally avoid poor programming.  Sure some Flash banners suck up your CPU, but it is just as easy to code an infinite loop in Javascript/HTML 5 as it is in ActionScript.

4. Battery

For the most part this is the same issue as performance except for the fact that Steve refuses to admit that Flash can be used for something other than video.

Also, while its a little late to the game, there is a hardware decoding chip for the “old” video format Steve talks about:

5. Touch

This one is ridiculous.  First of all, there are a million non-Flash websites out there with mouse over actions all over the place.  They work just fine on most mobile devices.  Second, Adobe already has a touch API in place for Flash.  Third, suggesting that recreating an entire site or application in HTML 5 is easier than modifying a few roll over behaviors in the Flash source is absurd.

6. Third Party Developer Tools == Evil ( a.k.a. !Apple == Evil )

Consider for a minute what Steve is saying here: If Apple decides to add some new capability to the iPhone, third party development tools won’t immediately support the use of that new feature, therefore they should not be allowed.

Now, by that same logic, shouldn’t they disallow practically any third party software on the Mac platform?  After all, at some point they might implement 64-bit color in OS X, and Photoshop only supports 32-bit images.  Maybe the new iMacs will support Apple 9.1 surround sound; Ableton Live doesn’t support 9.1 – it’s out!  What if Apple wants to support Open GL 5 some day?  Well better not allow all those new games about to hit the Mac via the new Steam store from Valve.  Dang, Portal 2 would have been fun on the Mac, but it wasn’t created using XCode so…


There are two things that I am certain are awesome: lightning and recursion.  So the fact that I was able to use recursion in Flash to create a quick lighting effect is what you might call “double awesome.”  Some example images of the effect are below.  Click one to see it in action.

Fun With the BitmapData class

You can do all kinds of things with the BitmapData class.  One application that is quite useful is to use the draw method to copy all or part of a source image.  You can then manipulate your new copies any way you please without affecting the original.  I used this technique to create some interesting slide show transition effects.  Click the image to see it in action.

Slide show with effects

Related Posts with Thumbnails

Copyright © 2010. All rights reserved.

RSS Feed.