Screen Savers for the Mac using Flash

This is an evening project that turned out to be really cool. Let’s say that you’re a Macromedia Flash designer, and your clients ask you to bundle your nice Flash movie as a screen saver. What to do? For Windows there are free utilities to convert a SWF into a screen saver, but not for the Mac – and the first commercial one costs around USD 200!

I propose here a simple solution for this problem:

  1. Using Xcode, you can create screen savers (basically, Cocoa apps).
  2. Cocoa applications can host a WebKit component (basically, Safari).
  3. Safari can show local HTML pages (basically, “file:///” stuff).
  4. And HTML pages can show Flash movies (basically, <OBJECT> and <EMBED>)

The idea, then, is to bundle your own page, with your own movie, inside the screen saver bundle, and show the Flash movie this way. Easy said, easy done.

It all goes nice until… you try this solution :) The problem is, Flash movies loaded from “file:///” URLs are blocked by the built-in security mechanisms of Adobe… and you have to find a workaround for that. Mine was to follow the instructions on how to bypass the Flash security mechanism, and then create an installer package that will do what’s needed for you to enjoy the screen saver.

You can get both the project and the installer package in my projects section. I’ve tested the installer in three different machines, and it worked, so I hope it’ll work for you too :) Enjoy! As always, try this at your own risk. Murphy says that things can go wrong, so watch out.

Playing with Dashcode

I’ve been playing with Dashcode today, creating my first ever Dashboard widget (something that I wanted to do for some time) as part of a whole project I’m working on right now.

Basically I’ve discovered that there are, roughly speaking (and please correct me if I’m wrong), two kinds of Dashboard widgets:

  1. Those that you cannot resize, but have nice shadows, “glass” effects and gradients;
  2. and those that you can resize, but do not have shadows, “glass” effects and gradients.

There is no way to get resizable and shadowy widgets at once. At least, not that I’ve found. It seems like Dashcode generates at design time the background images (as a PNG file) for the widgets you’re working on (I suppose that this is done using Quartz), and this cannot be done at runtime (I suppose, again, because of performance considerations…!).

Of course I discovered this while creating a widget that would have had to look good and be resizable. Of course I couldn’t get both :) Another thing that makes me wonder about this dichotomy is this phrase in Apple’s own documentation:

Live resizing means that your widget can change its size and contents based on the user’s preference. Try to limit using live-resizing to cases where it is absolutely necessary. If your content can be shown in a fixed, simple user interface, do so.

All in all, my first impression of Dashcode is that it is a fine IDE, somewhat buggy, but fine for what it does. I still prefer TextMate for editing the JavaScript code inside the widgets, but that’s a personal preference. The workflow for creating widgets is easy to follow, the object model is easy to understand, and I could have a reasonably useful widget in just a couple of hours of work.

Install MySQL_python in Leopard

I wanted to make my Django blog engine work on Leopard using MySQL as a database engine. I had a hard time making it work, partially because of my lack of knowledge of Python, partially because I am using MAMP instead of a “/usr/local/mysql”-like MySQL installation, partially because of Leopard itself.

The problem is, basically, that if you try to do the “easy_install MySQL_python” thing, it won’t work in Leopard (the compilation of the native code fails). Here’s how I made it work, following the instructions in this post in the MySQL forums, and doing some tweaking manually. Continue reading

Django & Leopard & the UTF-8 error

If you use Django on Leopard, you might encounter a strange “Locale UTF-8 not found” error when running your application. This is due to a bug in Terminal.app, albeit an easy to fix one: just go to the Preferences pane / “Settings” page / “Advanced” tab and uncheck the “Set LANG environment variable on startup” checkbox. Reopen your Terminal session, load the Django application and voilà! Your bug has disappeared. The screenshot below might help too:

solution.png

Hope this helps!

PS: yes, I’m doing Django and hence Python these days ;)

Argentina and the World Clock Dashboard Widget

As you might know, Argentina has changed its timezone today from GMT-4 GMT-3 to GMT-2; as a result, Apple’s World Clock dashboard widget does not (currently) show the correct time for our preferred tango+asado+soccer city.

This happens because the code of this widget calls the “TimeZoneInfo.currentTimeForTimeZone” method (line 582 of the World Clock.js file), which is provided by the runtime, and thus you have to wait until Apple provides a fix for it (please correct me if I’m wrong!).

Since Dashboard Widgets are JavaScript-based, I’ve copied it and created a new one with a small fix in lines 18 and 581 of the World Clock.js file, which makes it show the correct time for my birth city. Of course, this will change in March (when Buenos Aires falls back from GMT-2 to GMT-3) so you might want to fall back to the default World Clock widget when that happens (or when Apple fixes the time zone information in Mac OS X).

You can download the widget! As always, I’m not responsible of any problem it might bring to your system (in mine it works fine though!).

Before and after:

before.png after.png

This was effectively my first time dealing with Dashboard Widgets (something I wanted to do for some time…) I hope to create a real one soon!

Updating RubyGems and Rails in Leopard

If you just installed Leopard and the developer tools, you’ll find out that Ruby on Rails is there, ready to be used. But of course, it’s Rails 1.2.3, which is fine, but it turns out that last Friday Rails went 2.0. Not only that, but RubyGems was updated to 0.9.5 lately too… and you’re dying to have everything up and running on your system.

So how to proceed? Follow these instructions:

  1. Open Terminal.app
  2. $ sudo gem update --system
  3. $ sudo gem install rails
  4. $ sudo gem update

If you just do “gem update”, then the current Rails installation will be broken. You must do ‘gem install rails” (which seems odd, because it was already installed, after all). The thing is that since you’ve updated RubyGems with the command 2) above, then you need to re-install Rails. I haven’t tried with other gems, but it could be the same situation for them.

Update, 2007-12-19: Here’s another solution for this problem!

How to make in X11 so that the focused window follows the mouse?

Another long title.

Just a quick one, not to forget: in Apple’s X11, if you want to have the focus follow the current window, just type the following at the terminal window:

defaults write com.apple.x11 wm_ffm -bool true

Restart X11 and that’s it! This is particularly useful in apps like Gimpshop that have several open windows simultaneously (for the palettes, the layers, and the images themselves).