Archive for February, 2004

Searching Through XML Objects

It’s not exactly XPath, but it’s handy. The ActionScript 2.0 SearchableXML object below will help find elements in an XML object quickly. Assume, for instance, that you have an XML file like this:


<software>
<tools>
<product name="Flash" version="MX 2004"/>
<product name="Dreamweaver" version="MX 2004"/>
</tools>
<servers>
<product name="ColdFusion" version="MX 6.1"/>
<product name="Flex" version="1.0"/>
</servers>
<foo>
<bar>
<baz>Have a good weekend</baz>
</bar>
</foo>
</software>

The SearchableXML object will let you do this:


import com.macromedia.xml.SearchableXML;

var myXml:SearchableXML = new SearchabelXML();
myXml.parseXML(xmlFileAbove);

// Returns the Flash and Dreamweaver XML elements.
var allTools:Array = myXml.findElement("software.tools");

// Returns the ColdFusion and Flex XML elements.
var allServers:Array = myXml.findElement("software.servers");

// Returns "Have a good weekend"
var msg:String = myXml.findElement("software.foo.bar.baz")[0].firstChild.nodeValue;

Here's the code:


/**
* Adds some search functionality to the XML object.
*
* @author Christian Cantrell
*/
class com.macromedia.xml.SearchableXML
extends XML
{
/**
* Iterates through the XML object, looking for a specific
* element or set of elements.
*
* @path A dot delimited path to the element you're looking for.
*/
public function findElement(path:String):Array
{
var pathNodes:Array = path.split(".");
var currentChild:XML = this;
var elementArray:Array = new Array();
for (var i = 0; i < pathNodes.length; ++i)
{
var children = currentChild.childNodes;
for (var j = 0; j < children.length; ++j)
{
if (children[j].nodeType == 1 && children[j].nodeName == pathNodes[i])
{
if (i == (pathNodes.length - 1))
{
elementArray.push(children[j]);
}
else
{
currentChild = children[j];
}
}
}
}
return elementArray;
}
}

Disclaimer: Only lightly tested for a project I just started working on. Let me know if you find any bugs.

Breeze Does it All (including 3-D)

Naturally, I have participated in many Breeze Live events, and I have used Breeze for simple presentation generation, but the other day, I used Breeze and Breeze Live for the first time to conduct full-scale meeting and software demonstration. Man, was I impressed.

I started off with a brief presentation which I shared with about 50 participants. The presentation was generated from a PPT file which I uploaded right through the Breeze interface. Next, I shared my desktop and conducted a software demonstration, and ended by handing the meeting over to someone by making him a presenter. He then had full control of the meeting, and simply handed control back to me when he was done. We switched into discussion mode and spent some time answering questions, and when we ended, I felt like I had been just as effective over Breeze Live as I would have been in person. And we didn’t even use any of the streaming audio and video features!

What impressed me most was how simple and fluid the whole process was, and that both Mac and Windows users were able to participate equally (we have a lot of Mac users at Macromedia). I even discovered that Breeze can render funky metaphysical infinite 3-D hallways by sharing and previewing your desktop simultaneously:

Laptop Advice

Few topics evoke such numerous and passionate responses as the question “Which laptop should I buy?” I have seen a couple of pretty good discussions recently on different lists, so I thought I would give people an opportunity to compile some thoughts here (available to those Googling for advice).

What’s my favorite laptop? Well, I’ve owned an IBM ThinkPad, Compaq something-or-other, Zenith, Toshiba Satellite, Sony Picturebook, Apple iBook and two Apple Powerbooks (both 15″ models). Which do I like best? No surprise, but the Powerbooks have been the best overall. They are very well constructed with great features and a very nice screen. If I were a PC user, though, I would use a ThinkPad, no questions asked. My IBM was very tough, and I’m sure it is still in use somewhere in the world (I sold it on eBay a couple of years ago). My Sony was probably the coolest in terms of wow-factor, but it was a little too proprietary for my taste (Sony writes a lot of their own drivers for their hardware). I probably wouldn’t buy a Sony now, although I continue to believe that they make some of the coolest laptops around, and I wouldn’t discourage the purchase of a Sony, as long as you don’t intend to try to run Linux on it. My Toshiba was great, but big, plastic and heavy, and my Compaq and Zenith were too old to be relevant to a modern discussion.

But don’t rush out any buy a new Powerbook just yet. Make sure the screen and warping problems have been fixed first. I have the very last model of the “old” Titanium Powerbooks, and it’s solid as a rock because the form factor has been tweaked and revised over probably three or four years. The new Powerbooks (though clearly superior in features, hardware, etc.) have some screen and warping issues that Apple needs to work out. Once I’m sure the issues have been fixed, however, I will probably start keeping my eye out for a new 15″ Powerbook.

So my questions to you are:

Which laptops do you like best? Why? What kind do you have? What do you think of it? What kind do you wish you had?

Oh, and don’t forget to take the new survey, too.

Updating ALL Your Flash Players

If you need to update your Flash Player browser plugin, you can go to just about any page on Macromedia’s site and find a link to the Macromedia Flash Player Download Center. But why update just your plugin when you can update your plugin, Active X controls, standalone player and Flash Test Movie players all at once? There’s a page on the Macromedia Flash Support Center that lets you download an executable that will do it all.

Some Flash Player facts:

  • The most recent Flash Player version is 7.0.r19.
  • The plugin, Active X control, standalone player and test movie player are all up to 7.0.r19.
  • Download the plugin/Active X update here.
  • Download updates for all players here.
  • Find out which player versions you have (and test them) here.
  • Find out which test movie player you have by tracing the variable $version.

Running JRun and ColdFusion with Java 1.4.2 on OS X

NOTE: The solution below is neither supported nor endorsed by Macromedia. Use at your own risk!

Most of you running JRun/CF on OS X are aware of the fact that we have been stuck with Java 1.3.1 while everyone else has gotten the benefit of newer versions of Java. For reasons unknown (at least to me), editing your jvm.config file and changing java.home to point to a newer version of Java did not work. Fortunately, there is another way. CD into JRun’s lib directory, and type the following command:

java -jar ./jrun.jar -start default

I have the process scripted. Below is the meat of my “start.sh” script:


#!/bin/bash

JRUN_HOME="/home/cantrell/Unix/JRun4"
LOG_HOME="${JRUN_HOME}/logs"
java -jar ${JRUN_HOME}/lib/jrun.jar -start default admin \
1>$LOG_HOME/default-out.log 2>$LOG_HOME/default-err.log

Unfortunately I have found that I have to start the admin server along with the default server in order to affect the JVM’s classpath (I need to add drivers for PostgreSQL). For some reason, using the -cp flag hasn’t worked. Still looking into that.

Anyway, once again, this is not a supported configuration, and if you choose to try it, you are doing so at your own risk.

Palm to End Mac Support

Being both a Mac and PDA fanatic, I found this bit of news very disturbing. Apparently, PalmSource is rewriting the Palm OS from scratch once again, and this time, there will be no support for synching with Macs. The project is codenamed Cobalt, and in order to provide better integration with Outlook, the OS is architected in such a way that it will not be compatible with Macs.

I find this an interesting decision since Palm basically has a monopoly on the Mac platform. The only reason I use Palm is because I use a Mac, and I don’t have any other choice. If I used Windows, I would happily use a Pocket PC device and enjoy such revolutionary concepts as multi-tasking. And, of course, I would have Flash Player 6. I guess the reality is that a monopoly on something as small as the Mac market is not a terribly impressive monopoly, so in the game of numbers, Mac users are about to lose out.

The big problem is not that Mac users are losing Palm support, but that we are left with no alternatives except an iPod and maybe a Bluetooth mobile phone. Although the Palm platform is less sophisticated than Pocket PC, it sure beats trying to take notes on your phone and looking up appointments on your iPod. And Sony Clies are so cool that it’s very easy to forgive and even forget the shortcomings of the Palm OS.

Yes, I know there are third-party solutions for Synching Pocket PC devices with OS X, and that there will be third-party solutions for synching Palm OS 6 with OS X, but considering the fact that Apple’s iSync is still far from usable, I’m not sure I’m willing to gamble on the solutions over at markspace.com (if you have experience with MissingSync, please let me know what you think!), although it’s looking like I may not be left with much of a choice.

Palm’s announcement makes me think that maybe they know something we don’t. Maybe Apple is preparing to launch their own PDA. I’m not one to perpetuate rumors, but let’s look at the facts. The iPod gets more like a PDA with every update. It has fantastic battery life, more capacity than any PDA ever built, now comes with a cradle, and has already established an impressive market. And Apple has been diligently working on iSync, Address Book, iCal and even Stickies. Suppose Palm knows what Apple is up to. Why would they compete? Mac users prefer Apple brands, so if I could buy a good Apple PDA, why even consider a Palm? (If you have Safari, why use IE? If you can get an iSight, why use a Logitec?)

My guess is that within a year, Apple will announce a PDA, which Palm knows, so they have decided to focus on the Pocket PC and Microsoft markets with their new OS. If I’m wrong, I guess I’ll either switch to Windows, take my chances synching a Pocket PC device with OS X, or go back to jotting down notes on the palm of my hand.

Flash and the Apple iSight

Someone asked me recently if the iSight works with Flash, and the answer is that it works great. You may have have to update your Flash setting, however. If you are finding that your iSight isn’t working with Flash, right-click on any Flash movie and choose “Settings…”, then click on the camera icon. Choose “IIDC FireWire Video” from the menu. You can also use the iSight for audio by clicking on the microphone icon and choosing “iSight”. I tested it with a Flash Communication Server application, and the it worked great. Now we just need to change the Flash camera icon from the spherical Logitech-like form factor to the slim, lithe, cylindrical look of the iSight.

Mac and iSight users, be warned. I’ve have had two OS crashes during video chatting (with Scott Fegette) using iChat AV Public Beta 1.2 v151, and two other OS crashes that I have not been able to pin on anything in particular yet. When I upgraded to Panther, I started using iChat AV (in conjunction with Proteus) and an iSight, so it’s hard to say what is causing the crashes, but I’m in the process of narrowing it down now. Any suggestions?

Preserving Star Wars History with ColdFusion

originaltrilogy.com could prove to be one of the most important websites of our time, and I’m proud to say it’s powered by ColdFusion. The purpose of the site, in their own words:

“George Lucas doesn’t plan on releasing the original theatrical cuts of the first Star Wars trilogy on DVD — or any other home video format for that matter. They’re gone forever. The point of the petition is to try and change his mind.”

ColdFusion and Star Wars: an unbeatable combination, and a noble cause.

Chatting, Evolved

I finally broke down and bought an iSight over the weekend, and I’m very impressed with it. So far, I’m not getting a huge amount of use out of it, however, since I only know a couple of people with both Macs and iSights, and I don’t like the idea of one-way video chat (it just doesn’t seem fair). Fortunately, the newest version of AIM (5.5) is supposed to have a video chat feature that is compatible with the public beta of iChat 2.1. I tried to get it working at home with a Windows machine upstairs, but I think you need Windows XP, and I’m still using 2000. If anyone wants to give it a try, my AIM screen name is “qantrell66″. (For old-fashioned text chatting, my ICQ number is “57644155″).

CFCs vs. UDFs

Ben Forta recently blogged about a conversation he had with Simon Horwith in London about when to use a CFC versus when to use a custom tag. I completely agree with the conclusion they came to, which was basically that CFCs make sense for logic and data abstraction, and Custom Tags primarily make sense for presentation.

Another interesting question to ask is when should one use CFCs versus UDFs? While I would much rather have this conversation at a Starbucks in London, I guess my weblog will have to suffice.

Since the release of CFMX, I actually find myself writing very few UDFs. I still find them occasionally useful for “one-off” application-specific functionality, but in general, I’m much more inclined to write a component for the following reasons:

  • State: Components can contain state while UDFs cannot. For instance, many native ColdFusion functions require you to pass in the data being operated on in addition to parameters to configure the operation. Having a stateful data structure can promote better encapsulations, make your code cleaner, and in general, be more convenient. Even if your function appears as though it should be static, why not put it in a component and allow yourself some flexibility to expand the functionality in the future?
  • Logical Grouping: I like to be able to put related functions together in a single component rather than just create a bunch of basically unrelated functions. For instance, one could imagine a single date component with 41 different functions as opposed to 41 date-related functions among a total of 235 unrelated functions.
  • Organization: I like having the ability to organize my components into packages. Although you can organize your UDFs into directories, packages provide additional benefits and flexibility.
  • Inheritance: I honestly don’t use a ton of inheritance with ColdFusion components, but I do use it occasionally, and I think my application architecture benefits from it. Although UDFs can certainly invoke each other to achieve the “code reuse” aspect of inheritance, in general, inheritance allows for far more sophisticated modeling.

So how do you decide when to use a component versus a UDF? And who’s up for rewriting all 235 native ColdFusion functions, grouping them into components, and organizing them into packages?