Viewing By Category : flex / Main
March 9, 2009
timezone spatial locator: updated
minor update to the project, added search/geocode functionality (seems not everyone knows how to use a map). enter a unique city/state/country name (ie, "Big Lick Mountain, PA") and the app will try to geocode the location and find the timezone there. please note that for searches that return multiple places the app will (for now) just use the first.

updated demo here. you can download the source from riaforge.

January 6, 2009
timezone spatial locator
one of the challenges of trying to use timezones (tz) in an application is that there are so darned many of them--most of which aren't relevant to a given user. for example, have a look at the timezone CFC testbed. the list of tz just goes on and on (and on). you can narrow down the list somewhat if you know the user's location (maybe via geoLocation or, oh yeah, simply asking them), but big countries like the US will still have many tz and often tz IDs won't have much meaning to users. one idea to help with this issue that i've been kicking around for a while is to use a map to help a user pick a tz relevant to them. easing back into work this week i decided now would be as good time as any to put this idea into code.

i've put up an alpha version here. it's a flex 3.x "mashup" using google maps as the UI plus geonames to supply the tz info once a user clicks on the map.

some things to note:

  • it really is alpha quality, error handling, etc. isn't very pretty
  • the normal double click to zoom in google maps behavior doesn't work as my single mouse click listener seems to be swallowing all the double clicks, so use the zoom control instead
  • it's really too big to be of much practical use, ie a much smaller widget would be better for use on a page (i am as they say "design challenged")

once i iron out all the kinks i'll post the source in the usual places.

update: seems there's an issue w/google maps API where it also fires off a single mouse click event for any double click events, so you can't easily tell the two events apart. workaround was to add shift-key to the mouse click to get tz info for single mouse click.

update: there's some kind of issue w/an iphone app doing a DDOS on the geonames web services, please change your code to use ws5.geonames.org instead of ws.geonames.org.

you can download the source, such as it is, from riaforge.

December 21, 2007
mike's a monkey's uncle?
i meant to blog this earlier but got caught up in annual vacation, recovery from said vacation, etc. it looks like former macromedian/adobite and cf man about town mike nimer has joined up with digitalprimates.

congratulations and good luck guys.

June 1, 2007
coldfusion 8 minor flex annoyance
if any of your coldfusion 7 CFC methods have a return type of "any" these will probably fail in coldfusion 8 and flex w/the dreaded TypeError: Error #1009: Cannot access a property or method of a null object reference error. the public beta seems to have made type conversions to flex more "rigorous". you should also watch out for cases where your return type is "struct" and you're really returning a typed object, cf8 will blast away all the object bits & turn the returned object into a real coldfusion structure (ie your object's key case will become UPPER case and since flex is case sensitive this will lead to a certain amount of head scratching). in almost all the cases i've looked at both of these cases were simply sloppy coding/QC (majority were left over from my dithering around about exactly what to return to flex, "any" worked well in those cases ;-) & could be "fixed" in a few seconds.

while it's a short term annoyance i think this is probably for the better long term.

update: tom jordahl's mentioned that the "any" bit will get fixed for the final release.

September 2, 2006
when is a flex event listener not an event listener?
as i mentioned in my last post, i'm porting a js UI lib over to flex/flash. one of the things this library does is provide several tools for working with images (well map images actually), it does stuff like measure distances, areas, and angles, rubberband zoom boxes (oh how i wish google map et al would wise up and add this functionality natively, click to re-center the map image then do a separate zoom is for the birds), redline maps (mark up the map image with user annotations like "for heaven's sake don't dig here"), etc. the approach we used was to handle each mouse event separately (up, down, move, etc.) and hand off the event processing to whatever the current tool was, essentially a big switch box. well having read up on and researched flex's event processing i thought i'd get "fancy" and add/remove event listeners as a user changed tools. here's the approach i took:
  • create an mxml image object and hang an original set of listeners off it:
    <mx:Image id="theMap" height="400" width="600" source="" toolTip="the map" useHandCursor="false" mouseMove="utils.showCoords(event); utils.doZoomBox(event);" mouseDown="utils.doZoom(event);"/>
  • remove the current listeners and add the new ones as the user changed tools:
    theMap.removeEventListener(MouseEvent.MOUSE_DOWN,utils.doZoom);
       theMap.addEventListener(MouseEvent.MOUSE_DOWN,utils.doPan);

this worked perfectly the first time, then the application would fallback to the original set of listeners defined in the mxml image object (i didn't actually see this at first, i just noticed it fellback on the wrong set of listeners). that is, if i switched to a tool to pan the map image, it would work the first time i panned the image, then it would go back to the zoom tool for the next mouse event. couldn't figure this out after a couple of days, went to the flex-coders list, no joy. another day or so of slowly banging my head against the monitor and i finally had to bother matt the-answering-machine chotin. i guess it took matt about 2 minutes to see my self-inflicted problem.

the problem was that the listener i was removing wasn't the same "listener" as i had originally hung off the mxml image object. when you add a "listener" like that in mxml, it isn't actually a listener, rather it's simply code that will get executed. so when i went to remove it and add a new one, what happened was that only the new listener was added, giving each mouse event two "listeners", the original one in the mxml object and the new one added via actionscript. who knew?

the proper way to handle this is to not define "listeners" on your mxml objects but rather add them during initialization. though in fact matt advised that the original js design was the more "traditional" approach, so that's the method i ended up implementing.

i guess this is another example of the kind of support adobe provides. even though matt is now further up the product food chain he still takes the time to answer technical questions. the same can be said for damon, tom and mike on the ColdFusion team (well when mike was still with adobe anwyay). while i suppose there are other communities with this level of company support, bet you can count them on one hand ;-)

September 1, 2006
hello flex builder 2, goodbye old workstation
doing mostly ColdFusion work and doing it with cfstudio 5 and occasionally eclipse and lately cfeclipse, i was perfectly happy running an "ancient" workstation. how ancient? an intel pentium III (797 mhz) on an intel motherboard that maxxed out at 512 mb RAM (which i used to think was a lot). it's hard disks got bigger, win2k gave way to xp (way later than everybody else), WIFI supplanted 10T, monitors have come & gone, i've pounded several keyboards to pieces as well as dropped a half a dozen mice off the desk to their doom but that old workstation just stayed dependable, the only thing i've ever done was replace the power supply a couple of years ago. i'd blow the dust out of it 2-3 times a year (Thailand is a fairly dusty place) and maybe defrag the system disk 4-5 times a year but that was it as far as maintenance went.

now along comes flex builder version 2.0 (i won't say anything about 1.5, there might be kids present ;-). while it starts up in an acceptable amount of time (not instantly but snappy enough to get my game face on), compiling apps, especially given the habits i've developed from ColdFusion of testing incremental changes and saving code every chance i get, is getting to be a drag. testing concepts--i'm fairly new to flex, so everything is a "new concept" to me & needs to be tested, i don't believe a word the docs says ;-)--and smaller, focused components, it's not too bad. but boy oh boy, complex stuff is taking longer & longer & l-o-n-g-e-r. i tried doing something else, reading email, blogs, listening to matt & peter's podcasts but that just made things worse, stealing RAM from eclipse. so i took to getting up from my workstation & getting a cup of coffee during compilation but with all that extra caffeine in me, i started scaring people and chasing pets in the neighborhood so i've had to find another solution ;-)

since i've more or less lived in a cave when it came to new hardware developments, i'm not sure which way i should jump (except no macs, too old to learn that much), though i do know i want one of those fancy-pants LCD screens. then there's the psychological berlin wall i'll have to hop over when it comes to years of the apps i've accumulated on this box. i hate the thought of wasting a day or more getting the old stuff installed on the new box as well as rummaging around in file cabinets looking for install CDs and serial numbers, etc. in the end though, i guess it's time to put old yeller to sleep.

so anybody care to hand out some advice on hardware specs for a flex capable workstation?

btw i really like flex. i'm in the middle of porting over an old js GUI library (i guess it might be called AJAX these days) and a couple of days ago i threw out gobs of skanky old code that handled browser brand and version quirks. i suppose the more modern AJAX libs handle this stuff transparently but back then it was all on the developer and i for one, am really glad that this probably won't be something i'll have to think about again. and compared to js, flash/flex just seems simpler and more natural to me (at least since i haven't read much about stage, movieclip or timeline lately).

August 1, 2006
just the flex, mam
relative to ted patrick's just mxml and ActionScript 3 site i guess us ColdFusion folks are verbose blabbermouths ;-) for someone new to Flex, i love it's simplicty and get to the point style.

very cool.