Welcome to the eighth entry in the Intermediate ColdFusion Contest. The earlier entries may be found at the end of this post. Today's entry is from Scott Johnson. Before reading on, please check his application here. You can download his code from the download link at the bottom. Please respect the copyright of the creator.
Wow. I like Flash Forms - but I was amazed at this one. I was certain he was using a normal Flash file, but I noticed the loader looked just like a normal Flash Form. I opened up the code and saw that I was right - Flash Forms. Now - to be honest - he is pushing things a bit. He uses Flash Remoting and certainly that is the kind of thing that may not work in future versions of ColdFusion.
I am absolutely in love with this Flash Form - but due to the size - I'm going to suggest people download the zip and check out the file there. Not only does he use remoting, he employs some custom styles as well.
So with all that raving - now I'm going to nit pick. First off, his application.cfm file looks like so: (Note that I had to modify the appPath variable for my server.)
<cfapplication sessionmanagement="true" name="BlackJack">
<!--- PLayers starting amount of money is set --->
<cfset APPLICATION.startAmount = 1000>
<!--- Set the path that the application resides in, with respect to the host --->
<cfset APPLICATION.appPath = "sjohnson.bj">
<!--- if there is no blackjack cfc or if init variable is defined, create a new instance --->
<cfif NOT IsDefined("SESSION.BlackJack") OR IsDefined("URL.init")>
<cfobject component="components.BlackJack" name="SESSION.BlackJack">
<!--- initialize the cfc --->
<cfset SESSION.BlackJack.Init()>
</cfif>
He correctly caches his session variable, but doesn't do the same for his application variables. Therefore, every hit will recreate both startAmount and appPath in the Application scope. Not a horrible mistake - but something he should address.
Oh - and he didn't var scope. Getting tired of me saying that yet?
One last note. I had to modify the darn appPath variable everytime I moved the code. Can anyone think of a good way to create a "dot" path from the current folder?
Earlier Entries: