Flex 101: This was a very beneficial all-day training session showing how to get started using Flex. It started with Understanding Flex and Flex products, through events, event handling and custom events, and spent time demonstrating how to use AMF to retrieve data from a Java back end. Although I have been using Flex for a year or so, I learned it piecemeal, so it was great to see an organized presentation from A to Z, so to speak. Thanks to Matt Boles for organizing and presenting the session.
High Points:
- The Tour de Flex application presents all the Flex widgets in one place, including sample code and demos.
- Using Flex Builder: dragging a tab to the bottom or side of the main window will open up that code in a 2nd window, so that you can view 2 files at once.
- Event Handling - handle events as close to the source as possible. Where you have 2 sibling objects that need to communicate using custom events, handle the event at the closest common parent of the 2 objects.
- The reason to create custom events is to carry value objects - data - from one component to another.
- Pressing ctrl-space in Flex Builder will bring up code hints. This even works inside a data binding - type {} first, then go between the curly braces and hit ctrl-space or start typing.
- [Bindable] - sets up an event listener under the hood so that any changes to the variable flagged bindable cause all objects listening for changes to be updated.
- Using AMF will result in 10 to 100 times better performance over the web. Objects are retrieved as real objects and can be paired - an ActionScript object paired with a Java Class, e.g.
- Using the embed tag - only use it if it is a small image or icon. Large images or extensive use of the embed tag causes the .swf to bloat, which then means that the user must wait too long for the .swf to download
- When referring to objects in Flex Builder, it isn't necessary to type the namespace, as in <mx:...> or any other namespace. If they are imported into the file, just start typing the name of the object, like TextInput or KeyPanel. They show up in the code hinting. Saves typing! .
- During code hinting, the class won't get imported automatically if you do any back-spacing or corrections to the object. If this happens, when you get to the end of the work, use ctrl-space - this will import the class automatically.