Tuesday, 27 February, 2007

Hosting change

I've changed hosting providers from SectorLink to lunarpages.  These things don't happen overnight, so it might be a few days before DNS propagation has everybody seeing the new site.

If you're seeing this page it means that everything's working for you.  This page is on the new site.

It's possible that my email is not working yet.  If you get a bounce back from sending mail to me or to Debra, please try again in a couple of days.

Sunday, 18 February, 2007

Python and path resolution under Windows

A new project has me diving into Python.  Python is an interesting and somewhat quirky language:  quirky in that it does some things much differently than how I've seen them done in other programming languages.  With just a couple of days' experience, I can say that I like the model more than I like PHP, mostly because Python shows more forethought--design--whereas PHP looks like it started as a clever hack that evolved.  I'll be the first to admit that this is a totally subjective opinion that's based on very little familiarity with either language.

I ran into an interesting problem today when trying to get the urlgrabber package working.  I downloaded and installed the Python module, ran the unit tests, and was told that everything worked.  But when I tried to run the example program, called urlgrabber, I kept getting an error message trying to import urlgrabber.grabber.  This was very odd because the sample programs had no problem importing that module.

30 minutes searching the Web didn't reveal a solution.  It finally dawned on me that the problem might be that there might be a name resolution conflict.  The program called urlgrabber was trying to reference a module called urlgrabber.  This probably isn't a problem under Linux, but under Windows it appears that Python was looking in the current working directory for the urlgrabber module.  What it found instead was the urlgrabber program itself.  It then searched for grabber in that directory and didn't find it.

I confirmed my suspicion by renaming urlgrabber.py to xxx.py.  The program works fine now.

This all makes sense.  Windows always searches the current working directory first when looking for programs, DLLs, and other things.  Only after that does it start searching the directories identified in the PATH and in other places.  Linux, on the other hand, does things differently.  In particular, you can configure Linux so that it specifically does not search the current working directory.  This is very common, in fact, when running as root.

Problem solved.  For now.  On to the next one.

Wednesday, 14 February, 2007

Disabling a Flash SimpleButton

The enabled property of the flash.display.SimpleButton class, according to the Flex Language Reference, is supposed to enable and disable a button.  The documentation reads:

A Boolean value that specifies whether a button is enabled. When a button is disabled (the enabled property is set to false), the button is visible but cannot be clicked. The default value is true. This property is useful if you want to disable part of your navigation; for example, you might want to disable a button in the currently displayed page so that it can't be clicked and the page cannot be reloaded.

Unfortunately, it doesn't seem to work.

If I set enabled to false, the button no longer responds to the mouse moving over it.  That is, the button states don't change when the user moves over or clicks on the button.  But a click on the button does result in a CLICK event being sent to the event handler.  So although enabled prevents the display state from changing, it does not prevent the button from raising events.  In other words, enabled is useless.

However, you can disable a button by setting the hitTestState to null.  The Flash runtime tests the mouse position against the hitTestState object to determine if the mouse is over the button.  hitTestState is usually set to the same value as upState, but if hitTestState is null then the button has no presence as far as the hit testing code is concerned, making it impossible to roll over or click on the button.

So I wrote the following little function to enable or disable a SimpleButton object:

private function enableButton(button:SimpleButton, bEnable : Boolean) : void
    if (bEnable)
	button.hitTestState = button.upState;
	button.hitTestState = null;

It seems like the enabled property should work as advertised. I wonder if I have an older version of the Flash 9 runtime, and that bug is fixed in an update. I guess I'll have to go hunting.

Wednesday, 14 February, 2007


The HyperBike is the ultimate human-powered land vehicle.  The thing is a work of art and an apparently effective transportation device.  The inventor swears that you could get 50 MPH out of the HyperBike, although you couldn't convince me of that by how he operates the thing in a parking lot (in this video).  It looks exceedingly awkward.  The cranks for the foot pedals look too short, and the standing position doesn't look like the most effective way to operate the hand cranks.

But for all that, the HyperBike is really cool.  And the model posing with it isn't too bad, either.

Somebody in a car wouldn't able to say, "I didn't see it!", about one of these things coming down the road.  And if 50 MPH is easily achievable, I should be able to keep it at 30 or 40 without too much trouble.  A sustained 30 MPH over a flat course would be very nice.  I can't do that on my road bike for more than a few minutes.

Now where do I strap the grocery container so I can take this thing shopping?

Saturday, 10 February, 2007

Thoughts on Flash

I've been doing quite a bit of ActionScript coding recently, trying to complete a game I started some months ago.  More than anything, I need to complete a project.  I've been directionless for far too long, which has contributed to my recent mental state.  Focusing on this game--on completing the game--has helped me start to regain a little balance.  Although I'd like something to become of the game, the most important part right now is completing it.

The ActionScript language itself, as I've mentioned before, is quite reasonable; in most cases, a joy to work with.  It has rough edges, as do all programming languages, but overall I very much enjoy working with it.  The Flash environment, too, is nice, but I'm continually bumping my head against the "this isn't Windows" problem.  The Flash model is fundamentally different than Microsoft Windows and, whereas there are many similarities, the differences sometimes confound me.

The Flash event model, for example, is much closer to X Window than to Microsoft Windows.  Although I think I prefer the Flash model, my unfamiliarity with it has been the source of many head-scratching moments.  It does slow down the development process, but I also have very much enjoyed learning new things.

What's giving me trouble right now is that the Flash APIs don't appear to include the concept of a modal dialog box.  The Flex framework does, but at a cost.  Even the smallest Flex program is over 100 kilobytes in size.  Any meaningful program that uses Flex will quickly suck in more than 200 kilobytes of framework code.  That's just too much.  My game, which does not use Flex, is only about 220 K in size.  That includes all of the sounds and artwork.  Using Flex would probably double the size of my program.

Some may think it's silly, what with the wide availability of broadband Internet access, to be worried about adding 200 kilobytes to the download.  Afterall, bandwidth tests on my connection here at home report a download speed of about 600 kilobytes (yes, bytes, not bits) per second.  So 200 K takes roughly 0.33 seconds to download.  And 200 K means almost nothing in terms of storage these days, when computers regularly come with 80 gigabyte drives.

There is an issue on the server end, though.  Bandwidth charges start to add up when thousands of people download a program that's twice the size that it has to be.  It's hard to say if that's really an issue.  Some providers give two gigabytes of bandwidth per month with their basic hosting packages.  It would take 5,000 downloads to exceed the limit.

Some of my reluctance is undoubtedly aesthetic--the old assembly language programmer in me who hates to see all those wasted code bytes.  Whatever the case, I've committed to making this game without using Flex.  After that's done, I'll re-evaluate my options before tackling another Flash project.