Flex Step 0.1 Alpha

Flex Step 0.1 Alpha

Posted by Brad Wood
Sep 24, 2008 09:58:00 UTC
Wow, I don't know if I have ever been so happy to get such a simple piece of code working. I have jumped into Flex 3 with basically no knowledge in order to make some charting functionality and I can confirm that I hate learning new stuff. I mean, I love it AFTERWARDS; but that time at the very beginning when you don't have a clue why your code won't work, Google isn't your friend, and you swear you're the first person in the world to have just received that weird error message-- yeah, that is the part that sucks.I must say that when it comes to Flex, there just isn't as much information out there in the form of blogs and such when it comes to common error and problems when compared to ColdFusion. And there definitely isn't a great deal of info I could find about Flex and ColdFusion. A lot of the hits Google would give me pertained to PHP or Java. And there is almost zero info out there specifically for Flex 3 and CF 8. MOST of the Flex/CF stuff I found referenced Flex 1.5 or 2 and CF 7. Despite my setbacks, I now have a simple CFC which returns a query, and a simple Flex app with a bar chart which uses the mx:RemoteObject tag to retrieve the query and populate the graph with it. Sadly I must say that the flash remoting didn't "just work" for me the first 27 times. The most annoying thing is that I'm not quite sure why my flex2gateway didn't work, because it just started working and I don't know what changed. I'm happy it works, but unfortunately I didn't learn anything to apply to the problem the next time it arises. My first problem was that when I created my first Flex project, it asked me if I wanted to use ColdFusion for data access. Sure I said. Then it wanted me to browse to the local directory where my ColdFusion install was. Uhh... I don't have ColdFusion installed on my work PC right now. I just wanted to make a local .swf that would point to the CFC on my dev server. This was very frustrating, because I couldn't find anywhere on the internet where someone was telling me I HAD to have ColdFusion installed locally to use it with Flex, but the Flex Wizard seemed to be implying that because it wouldn't let me finish creating the project until I had chosen something. After looking through SEVERAL blogs I figured out that all the Wizard was after was the path to my services-config.xml file found in your ColdFusion install. This XML file has information about the Flash Remoting gateways and where they are located. I finished the Flex wizard by telling it I didn't want to use ColdFusion. Then I copied the services-config.xml file (and some other XML files it included) to my local machine and edited the ColdFusion endpoints to have a hard-coded path to my dev server's flex2gateway folder. After that, I went into the project properties and added a compiler argument -services "C:\my\local\path\services-config.xml" Now, I had another problem-- my flex2gateway folder (doesn't actually exists, there is a mapping for it in web.xml) wasn't working. When you navigate to www.myserver.com/flex2gateway in a browser you are supposed to find a blank page. There are a number of blogs out there for when you get a 404 error on that page, but I was getting a message that said, "The specified module cannot be found" and I couldn't find a SINGLE Google result to help with it. Furthermore, everyone seems to know that that URL should server up a blank page, but NOBODY seems to know how it is supposed to work, or where to start trouble shooting when it doesn't work. What complicated the matter is that directory worked with the default site in IIS, but not the one I was using. Well I finally tried some advice over at <CF-A-LOT /> which involved removing the IIS connectors and re-adding them. That fixed my problem but I DON'T' KNOW WHY! I looked and looked through the IIS setting for the two sites and couldn't find a single difference. Unfortunately this is an older version of IIS that doesn't allow exporting a site to an XML configuration file, or I would have done that and diffed them. There were some other vaguely annoying things to get used to. For instance needing to import the libs I needed in ActionScript. I don't mind doing it-- CF has just made me lazy. For instance, if you want to reference the return object from your RemoteObject call, you have to do this: import mx.rpc.events.ResultEvent; Additionally, ActionScript is strongly typed which kept messing with me when I would try to change the return data type of a function without updating the function declaration. What was worse than getting an error message, was no error at all. For instance, when I would load my Flex app and NOTHING would happen. No error, no message, just nothing. At first I thought maybe the debug output from ColdFusion was messing up my flash remoting, but then I found a cool class called mx.utils.ObjectUtil which has a toString() method that will print out a complex object for you to see it. It's a lot uglier than cfdump, but it works. It showed me that my column headers were coming back in all caps and my graph was looking for title case. FINALLY, I got it working. Now that I have a working example, I think I can get a bit more productive. I still have questions though. For instance, do I need to recompile my swf for EACH environment since the flash remoting endpoint will be on a different server? (dev.myserver.com, stage. myserver.com, www. myserver.com) Can I determine that programmatically, or pull it from a config file? I will continue to post problems as I work through them in hopes that it will help someone else.

Mike Rankin

This may seem like little help, but I've been using the new stackoverflow.com website for difficult tech problems and it seems to draw people out to provide solid answers. While there are still some problems with the voting system, it does seem to provide a pretty good feedback loop.

Brad Wood

@Mike: Thanks. That site isn't Flex specific, but it does look kind of cool. Sort of like the tech version of Yahoo! Answers. :)

Nick Kwiatkowski

You may want to check out some of the great publications on the subject. First there is the FAQU (particularly, issue #3 (red one), that covers Flex subjects. The second is the Flex-Authority (also by the same publishers), which is entirely about Flex. http://www.flex--authority.com

You can also check out my Usergroup's website, were we have posted many, many presentations about Flex and Coldfusion. http://www.TheFlexGroup.org

Good luck!!

Brad Wood

@Nick: thanks for the link. I will check out some of the presos on your user group site.

I have heard of FAQU (and have most of the issues). I have also heard of Flex Authority which has recently come out, but I don't have any issues of it yet.

Tariq Ahmed

Hey Brad, that was a good post. I know what you mean - although I'm an advocate of Flex, the first thing I do is flat out tell people it' s slower to work in than compared to something like ColdFusion (which definitly pampers us by making things rediculously easy to do).

Seeing coworkers go through these trials and tribulations is what prompted me to write a book on Flex (flexinaction.com) which attempts to point out the challenges you may encounter, or provide you with enough foundation so that you can tackle problems as I find working in Flex is a different mindset compared to CF.

E.g part of that mindset difference is the realization (IMHO) that CF is about making life easy for the developer. Flex is about making life easy for the end user. Not that you can't have both, but the priority of Flex has been to give developers the power to make great user experiences - and that doesn't mean just special effects and drag and drop. E.g. with CF you have control on the server side of things, you can slap in a bunch of load balanced quad XEON CPU 16GB of memory super computers... but with Flex you have no control over client hardware, so keeping the memory footprint and resource utilization low is part of the user experience (hence why Flex is strictly typed, why libraries need to be imported on an as needed basis, etc...).

Though all this is true for any client side/RIA technology.

Flex is beginning to mature as a product though. Flex 3 and CF8 made a lot of strides to make the data integration easier, and that'll continue with Flex 4 and CF 9. Though the theme for Flex 4 continues to be on the experience by giving developers more control over the customization of the experience (easier to skin, easier to incorporate themes from designers, etc...).

Hang in there Brad!

Brad Wood

@Tariq: Thanks for the note about your book. I am actually trying to find a good Flex 3 book to read right now. I will check Amazon to see if I can get it there. (I was looking the other day and don't recall seeing it)

Brad Wood

Hmm, looks like Flex 3 In Action hasn't been released yet according to Amazon. You'll have to let me know when it comes out. :)

http://www.amazon.com/Flex-3-Action-Tariq-Ahmed/dp/1933988746/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1222276960&sr=8-1

Tariq Ahmed

Will do! It's in the hands of the production team right now - they have 3 more chapters to polish off and it's done. So hoping that it'll be available in about 3-4 weeks.