ColdFusion 9 ORM, Flex 4 and ReferenceError: Error #1065: Variable * is not defined.
I have an annoying personality trait. OK, I am certain that I have more than one, but I am writing today about obsession; I tend to be tenacious when I can't get something to work the way I believe it is supposed to work. It has often been observed that when presented with a software problem that blocks progress, I can become obsessed with resolving it. A few years ago, my mother came to Atlanta to visit me when one such software problem was plaguing me. She could tell how unfocused — on everything but the problem — I had become. After a few hours of "last ditch efforts," I walked away from the problem only to think of the proper solution a few hours later. Luckily, that solution worked and I was able to spend quality time with my mother after a couple of late hours of coding.
Last week, another error presented itself. This time, the problem was a weird error I was getting from Flex while receiving data from ColdFusion. You see, I'd decided to take ColdFusion 9's ORM implementation for a spin and applying what I'd learned to a Flex project I've been working on. The logic for learning ColdFusion's ORM implementation was this: first ColdFusion ORM, then Java ORM/Hibernate, then .NET's Entity Framework which is used a lot at Measured Progress, my new employer. While I don't plan on becoming a full-time ColdFusion developer — or Java or .NET developer, for that matter —it is always good to acquire new skills to use when a good server-side developer is unavailable.
When learning new technologies, there are always risks when things get complicated. I typically always believe I've done something wrong. I obsess over my code to find errors. I double check documentation. I ask my peers. I isolate the problem. I have my code reviewed. I consult with people who have more experience than myself for advice. Typically, the process doesn't move past the "I ask my peers" stage but this time it was different.
The Problem
I was having some strange symptoms using Flex Remoting with ColdFusion. You see, I uninstalled and reinstalled ColdFusion 9 on all of my systems recently. Since then, none of my past Flex projects were working correctly. Errors were appearing where they were not before. Value objects were not being serialized. It wasn't a big deal at the time; not only was I unemployed, but the contract projects I was working on were not using ColdFusion. Recently, when I started working on a ColdFusion/Flex/AIR project, I had focused my efforts on the ColdFusion side of things before beginning work on the Flex code. With the server-code working well, I proceeded to move on to the "easy" part of the code for me: Flex. Unfortunately, that is when I began seeing an error every time I received typed value objects from ColdFusion.
ReferenceError: Error #1065: Variable * is not defined.
That's right: Variable *. I have no idea what that means. No one else I spoke to knew what it meant. I'd bet that only one or two software engineers at Adobe, those who worked on the AMF serializer, would have any idea what that error meant. Needless to say, it was perplexing. After pursuing the matter for hours, whining on Twitter, consulting the CF-ORM-DEV Google Group, and spending time screen sharing on Skype with Eric Fickes I finally decided to consult with the smartest developer that I know: Sim Bateman. He steered me toward the solution. After looking at the results in Charles, we saw that the correct value object was being passed from ColdFusion, but there were some capitalization issues with the class names and properties of these classes. Then, the cause of the problem became clear. Inside the services-config.xml file located inside ColdFusion's wwwroot/WEB-INF/flex folder is a setting that, by default looks like:
<force-cfc-lowercase>true</force-cfc-lowercase>
Ah, the wonders of the ColdFusion. I am pretty sure that I've seen this setting before, but to the life of me I don't believe I've ever needed to change it. With this setting, names Coldfusion Components (CFCs) classes will always be lower-case as will each of the property names inside those classes. So, if I am expecting a value object named User to arrive from ColdFusion, I would not get one with force-cfc-lowercase set to true. You will get an ObjectProxy object.
For typical Actionscript uses, we needed that setting to be:
<force-cfc-lowercase>false</force-cfc-lowercase>
With this change to the services-config.xml file, and subsequent restart of ColdFusion, we can have class names like User and properties like firstName in both our CFCs and Actionscript value objects. While I am fairly certain that most ColdFusion developers out there already knew this, but I wanted to make sure that if the error ever came up for someone else, a Google search might bring this blog post up for them. After making this change, my ORM CFC files came across the wire properly and the error went away. And things are making a lot more sense.
Now I have to make up for the hours of time that were wasted because I forgot about a setting inside a ColdFusion config file.
3435 Views
The Summer of Flash Page on My Site
I just wanted to point folks to the Summer of Flash Podcast page on my blog. I thought it might be good to have a place on my site where the podcast that features Garth Braithwaite, Stacy Mulcahy, Zach Stepek, and myself droning on and on about the Flash Platform. The "info" links are to the InsideRIA site pages that Garth put together for us, but I wanted to put all the information in one place so that I can refer people to it.
I totally enjoy recording this podcast. It is so much fun and honestly it's almost therapeutic for me. I don't work in a work site environment where there are a lot of Flash and Flex developers. In fact, I am the only one in the office who does that type of work, so getting to "hang out" online with the Summer of Flash crew is pretty healthy.
I want to thank the people at O'Reilly who have been so supportive. This was their idea and I feel lucky to have been asked to come along.
Oh, boy. Did I just say that hanging out with Stacy was healthy? What was I thinking?
3668 Views
Summer of Flash Podcast Episdode 1
I am pleased to announce that the first episode of O'Reilly's InsideRIA Summer of Flash podcast has been released.
In this episode, Garth, Stacy, Zach and I discuss the recently released Flash Catalyst Public Beta and what we like and dislike about the product.
We're continuing to record episodes and have lined up a few people from the Flash Platform to waterboard... er, grill for infor... er, interview about all things Flash.
If you have any thoughts, ideas, questions or requests, feel free to leave them in the comments for my entry here or at the entry on the InsideRIA site.
3446 Views
Tonight's Adobe Flash Platform User Group Meeting: Ryan Taylor and Flash Player 10
I am so glad that I know Ryan Taylor. Every now and then, Ryan will contact me and say "Hey, when would you like me to present?" I always seem to reply "Next month!"
Tonight, Ryan will be presenting some of the new features of Flash Player 10, currently in beta, at the Adobe Flash Platform User Group of Atlanta and Flash Meetup Atlanta meeting. You should attend.
3095 Views
Vote for Flex Builder Source Formatting (or Pedro)
I was reading a blog entry on Flex Builder Enhancements at InsideRIA last night and thought that I would bump the entry and my comment up to the surface for more exposure. RJ Owen's article laments features that are available from the Java Developer Kit and not a part of the Eclipse project itself, thus not immediately available for Flex Builder users. He cites useful features like "TODO", Snippets, Mylyn integration, and a fix to the Open Resource menu bug (something I had never run into). The article also links to where you can acquire these enhancements. All of these features are worthy of mentioning to my team here at Roundbox Global.
Snippets was one of t ne features that I was used to using in Flash Development Tool (FDT) back when I was doing Flash development on a regular basis. This feature allows developers to use templates to help speed up common coding tasks. If you want to be able to have code created for you via Snippets, you first create the template, then in your code type the string associated with the template and "bam" the code is there. All you need to do then is tab through the template variables you set up and enter the data you need. OK, so, it isn't that simple, but once you set it up and get it into your workflow it's powerful.
The comments for the article featured a few people fired up about the lack of source formatting. I mention the lack of this feature privately a while back and could never raise anyone's temperature. But someone else had thought enough about the feature to have entered a bug into the Flex Bug and Issue Management System over at Adobe. The issue, FB-8297, deserves the attention of anyone who wants source formatting in Flex Builder. At this time, the issue has 22 votes but I now feel certain that more people are interested than that.
Although FB-8297 is listed as a "Minor Enhancement", I am certain that Adobe's engineers will look at this issue as more than minor because it isn't just formatting ActionScript code similar to how Java code is structured; this task will require ActionScript, MXML and ActionScript+MXML all to be formatted by Flex Builder, something that is more than what the JDK is able to do. In the issue's comments, I've added some further enhancements to the issue — like making sure the "x" comes before "y" in the MXML which is something that drives me nuts during code reviews.
If you want this feature, vote for it.
3753 Views
Adobe Tells Me That My Code Sucks!
Adobe Tells Me That My Code Sucks!
Ah, bad habits. We all have them. In our lives and in our code. We let things slide. We don't clean up after ourselves. We assume that things are correct just because they work.
Well, not any more. Thanks to the heads up from Adrian Parr (I hate you for this, Adrian! I could have remained ignorantly blissful), Adobe has put us all on notice; Adobe has finally published Flex SDK coding conventions and best practices as part of their Open Source Flex initiative. I say "finally" because I believe that this is the very first time the mothership has begun setting some standards and coding Flex. Sure, there have been conference sessions and blog posts about this subject, but not this in-depth nor as specific.
Reading through the first few screens of this unfinished document I am already seeing things that I am doing incorrectly, according to this guide. Although I am quite certain that this guide is intended to standardize coding expectations for developers contributing to the Flex SDK, I am planning to begin following Adobe's advice more ridgedly in my own code in the future. In fact, I am recommending that this document be part of a guide for standard practices at my workplace. It makes a lot sense for me to make this recommendation because, ultimately, this guide is geared towards making it possible for large groups to code by one standard.
My worst habit? See the section labeled "Miscellaneous nomenclature." Ugh.
Which bad habits do you hate seeing from your team's code?
3952 Views
ColdFusion to Flex Remoting: UPPERCASE Rage!
How are developers handling the passing of Value Objects from ColdFusion to Flex using AMF?
Here is my situation: I am using ColdFusion as I believe that it was originally intended --- for rapid application development. The difference here being that the application is actually being built in Flex and ColdFusion is being used to manage the data coming from the server. I don't know Java and when I have to get work done without a Java developer available, I turn to my good friend ColdFusion to help me out. ColdFusion makes it easy for me to get my entire Flex application completed (well, as completed as possible) before the Java developers have touched their keyboards. Other than the specific problem I am about to describe, it appears to be working out for me.
I am quite certain that I am not the first person to run into this, and it seems like there should be a better solution than the ones that I have seen. On the ColdFusion side, I have a Employee.cfc that extends Person.cfc that extends User.cfc. I would like to make a call to my main CFC file passing a UUID and have that method return an Employee Value Object.
When I create the Value Object in a CFC and pass it to Flex all of the properties in the value object are in UPPERCASE. I could make all of my property names in my ActionScript Value Object UPPERCASE, but why the heck would I want to do that?!? I am baffled at why if I set something in a CFC to "id" I get it returned to me in Flex as "ID". For that matter, I should be able to make my property appear as "firstName" and have it return to me that way. I am pretty sure that there is a very technical reason for this, but damn... just damn.
So, I do have alternatives.
Since the query in the controlling CFC returns to Flex a perfectly formed Struct inside an ArrayCollection, I could just loop through the ArrayCollection and cast each Struct into a Value Object. The problem here is that 1) when I ask for one object, I should expect to get one object and not one object inside and array, and 2) when/if this project's back-end is converted to Java (which in this case is a certainty) I'll have to go in and change everything (and this is a problem, too, with the CFC solution. I am never going to get a Java developer to create a Value Object file that has properties in UPPERCASE. It's like screaming!)
Then, there is the option of creating a Struct from the Query and passing that along to Flex. I get what I want on the Flex side, but it totally ruins the object-oriented goodness on the ColdFusion side of things.
This is probably only bothering the Flex developers out there like me, but it's an problem I would like for Adobe to solve. Right now, since I know that this project's back-end will be created in Java eventually, I think I will be going with the last option of converting the Query item to a Struct. That is, unless someone comments here with an option I have not seen. Is there a better option? Is there a setting in ColdFusion 8 that will change this?
5727 Views
Now Reading: Gary Rosenzweig's ActionScript 3.0 Game Programming University
A few months back, Gary Rosenzweig sent out a few feelers for Flash bloggers who would like to read his latest book, ActionScript 3.0 Game Programming University (Amazon) from QUE Publishing. I volunteered, and Gary's publisher sent me out a copy.
For those of you who are unfamiliar with him or his work, Gary is old-school not unlike myself (no offense to you, Gary). We are both around the same age, he got his start in this crazy business doing some cool stuff in Macromind Director and we've both made that transition to Flash and ActionScript. Gary has written several books including Advanced Lingo for Games and Flash MX ActionScript Fun and Games. This new book is very similar to those books in that it covers the same games, only recoded for ActionScript 3.0. There are a lot of Flash developers who are struggling with making the transition from ActionScript 2.0 (or even 1.0) to using Flash CS3's ActionScript 3.0. It is my hope that reading what Gary has to say may assist me in giving some of these people advice in successfully making this transition.
In the coming weeks, as I go through this book, I will be reviewing the chapters pointing out the good stuff. But as I see now, the book's site is aggregated on MXNA! And has been since September! Take at look at FlashGameU.com for video tutorials about building games in Flash CS3 with ActionScript 3.0. It looks like Gary is moving beyond the book by Video Blogging new topics. Great!
2601 Views
Ryan Taylor's Animation System at Last Night's AFPUGAtlanta Meeting
I wanted to post an entry about last night's Adobe Flash Platform User Group of Atlanta meeting featuring Ryan Taylor from Schematic so that other user group managers and conference organizers could learn more about Ryan. Ryan's presentation on his Animation System was excellent and I believe that everyone at the meeting got a lot out of the session.
Ryan began the presentation explaining the differences between timeline and programmatic animation, showing the advantages and disadvantages to both. Then Ryan went into the math of animating, which quite honestly is the most math I've endured since high school (and that was a long time ago). I was truly impressed with Ryan's confidence and knowledge when it comes to programmatic animation. He really understands what makes an animation work and relayed that to the audience well.
Finally, after getting us the background that we needed to understand what his Animation System offered, Ryan demonstrated the many things that you can do with very few lines of code. Built in ActionScript 3.0, Ryan's Animation System can use either the Enter Frame Event or a Timer to control animations. I loved seeing that you can write one line of code to animate an on-screen object in ways that would normally take many, many more lines. By the end of his demonstrations I could clearly see the time and money that can be saved using this system. Finally, Ryan showed showed the presentation that John Grden used at MAX last week that combined PaperVision3D with Ryan's Animation System. It was very interesting.
Ryan's Animation System is currently at v2.0 and can be found here. Ryan said that the system has an MIT License and developers may do what they want with the code. Ryan has also gone to to trouble of documenting the system and providing all of the demonstration files within the code download.
Thanks, Ryan, not only for presenting but for giving back to the community.
2331 Views
FlexUnit Examples: The Forest for the Trees
Well, after my epic poem blog entry on Friday, I kept on looking for more FlexUnit examples. I found that if you keep looking you will find that they are right under your noses.
For instance, the AS3 Syndication Library has some here. And the AS3 eBay Library has them here. Just look in the test folder and down into the com/adobe... chain and there you are, multiple examples of unit tests and all kinds of asserts that you can shake a stick at, if you'd care to shake a stick.
These are not unit tests of projects. These unit tests actually test the APIs that Adobe released as open source. I believe that all of the projects that are listed on this page have unit tests in their source repositories. So, if you are just looking at getting into unit testing, these projects are a good starting place for examples.
Let me know if you find other examples and I will list them here.
3329 Views




