2007 CU221Presenter:
Rob Gonda
OverviewThe presentation was intended to be a hands-on workshop that would give the attendee an overview of Flex features and hopefully leave them with the ability to create a Flex application. The workshop was organized into a series of projects of increasing complexity each with a stub "run through" mxml file that we were supposed to edit during the course of the workshop with the intent of creating a functioning example. Setting up FlexIn my experience, Flex installed without an error, but I could not run or debug code. When I initially set this up, I didn't know enough about how Flex Builder was supposed to work to realize this problem. I initially thought you had to copy the contents of the bin folder to your server and execute there. The solution to that problem was to create another user with administrator privileges and to install and run Flex as that user. As usual, YMMV, but it appears that you have to be a REAL administrator to install and run Flex Builder. The CodeThe samples for Rob Note: There are usually two version of each like-named application; one is a stub that we were supposed to type the lesson into, and the other with a "final" suffix, is the finished lesson. If you want to see what is going on just look at the final version as the other is only completed in the first few lessons (this was before the hands-on nature of the presentation as abandoned due to time constraints. There were 17 examples plus the requisite "hello world" example in the presentation: 01-BasicThis was a simple form that showed how the click event of a button is handled. It also demonstrated how to debug this call and display its value in the debug perspective. 02-Basics IIThis project shows how to create a component and include it in your application. 03-The Event ModelThis project shows how to create and use events 04-Layout and ControlsJust like the title says, this describes organizing content on the page via Vertical and Horizontal boxes (VBox and HBox) which is essentially the row and column metaphor from the much-maligned (around CFUnited anyway) table layout. We also covered accordion and "toggle button" controls that simplify these presentation methods. 05-XMLHere we learned how to use an XML data source to populate a grid, which BTW, has all the features of the "best table sort ever". 06-Using View StatesThis one shows how to change the layout of a page dynamically based on an event. In the example, we used a button click and roll-over events to change the layout. This has the ability to hide portions of a complex form without switch to a new form and reloading the page. You can do the same thing with AJAX, but this seems a lot simpler. 07-GridsFun with Grids and XML data sources! Loaded via XML, editable cells, loading images, master-detail lots of examples some even work as advertised. But seriously folks I just had trouble with the editable cells example, other than that it is straight forward. 08-Dispatching EventsThis example was supposed to show how to create your own custom event handler to extend an object. Unfortunately I never got it to work as the "final" example was blank. Rob promised to email the fixed code so I will add that to the zip when I get it or when I get the chance to figure out what is going wrong. 09-RepeatersThis shows how to use a repeater tag to iterate over a data object and create controls dynamically. 10-4EXNow this one is really useful; a shopping cart app with 3 column layout, tree display, detail and add to shopping cart features. 11-Web ServicesA simple app that shows how to use, you guessed it, web services! 14-17 MVC via CairngormThese examples all are based on the Cairngorn framework, which allows you to use a Model -View - Controlled (MVC) design for your application. This was the most advanced portion of the presentation which took up the afternoon portion of the workshop. Here Flex actually takes a back seat to the Cairngorm Framework which lets you abstract your business objects through services, create custom event handlers, use delegates and value objects, all of which are better described in the [http://cairngormdocs.org/ Cairgorm documentation], so I Cairngorm Features
Debugging FlexYou can set break points in the Flex IDE, just like in Java code. When you start the app from the IDE you just select the Debug button rather than thr run button. To see the Debug unique features, you need to switch to the Debug Perspective, which can be configured to switch on debug start (at least that FeaturesDebugging lets you create breakpoints, examine variable values and look at call stacks, just as any good debugger, if you are familiar with Debugging Java you should be right at home. Of course this is all only Client Side debugging; to debug the server you need to use the ColdFusion debugger which I hear has been resurrected in MX8, but I haven't used it yet. Flex ComponentsFlex allows you to extend your application with Components (CFC There is one caveat to Components, they cannot be standalone applications in the Flex sense of applications.
Array CollectionsA result from a ActionScript call can use the Array collection object which has extended properties to allow sorting, which can be handy on the client side. Http CallsBy default return either a "result" or a "fault" event, so the error handling is simplified; all you need to do is implement both of these methods and the appropriate one will be invoked based on the return status of the call. Tips and Tricks
Flex HistoryFlex handles history by using a javascript library that manipulates IFrames in the flex presentation layer, actually it looks like all flex is presented via iFrames. MXML DeclarationWhen you are creating an MXML file, you need to make sure that the very first line in the file is the MXML declaration with no preceding white space. Action Script in MXMLAll action script code in the MXML file has to be in a CDATA tag so that you don Deploying FlexTo deploy flex, all you need to do is to copy the contents of the output folder to the web server, this is usually named "Bin" but it is a property of the project so it could be different. AlertsTo set an alert in Flex use the mx:controls.alert.show("My Debug Statement"). Search for folderTo tell flex to look for a file in a folder somewhere beneath the current root, you can use a ".." syntax, this lets you change the specific path – depth without breaking your code. Utilities
Service CaptureUsed to watch the results of a Web Service call. [http://kevinlangdon.com/serviceCapture/ http://kevinlangdon.com/serviceCapture/] |


