Intermediate Contest Entry 8
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:
Comments
By the way, I like this entry the best so far. that ajax stuff is a bit too clumsy to me. this is a solid game. one thing i like to see (that this entry did not have, but some others did) was the point total of my hand as i'm hitting. and the reason is sometimes i'll have like 5 or 6 cards and i have add them up in my head. that's not a big deal but what if i'm 1 point off. that could weigh my risks out differently when deciding whether to hit or stay.
I had 7 cards at one point. After that, the 7th card was never removed from stage.
I don't like the fact that it won't tell me the scope or count how may point I have in my hand.
I can provide examples if someone is interested...
Cheers
-Rob
agreed with Brett that it would have been really nice to display the current players totals with each card draw.
also i seem to have broken it by betting $1000 right off (yeah, i'm a gambler) and losing (ok, not a good gambler). the game didn't end, but i was unable to place a bet (kept getting an alert box telling me to "wager -1000 or less" in spite of the fact that i was unable to wager anything). hit the back button a few times to get back to the blog entry, clicked the link to start the game, bet $1000 again, lost (really not a good gambler), and now it tells me to "wager -2000 or less".
not gonna harp too much on the validation. my entry should be coming up soon and i already know a few things that are going to come up that are validation-related (among other things) :) just bringing it up in case scott wants to check into the code and see what's up.
With Flex Builder 2 on the horizon, it would seems likely that Macromedia would stray away from flash remoting and limit what you can do with flash forms through coldfusion. With some patience and actionscript know-how, you can build exciting RIAs with just coldfusion, basically another avenue to build simple flex apps. To define Flex and Coldfusion together as separate products that complement each other, I think they will need to limit what flash forms can do to avoid confusion.
<cfset request.rootpath = "#mid(Rereplace(cgi.path_info,'/*[^/]*/*','../','all'),4,(len(cgi.path_info)-4))#">

