Flex 2 Simple Presentation Application and Source Code
The application works by loading in a list of slides from an XML file, wherein each slide has an image and a title declared. It then proceeds to load in the images and presents them, in its default State, in a ViewStack (ala any Powerpoint presentation you've seen.) You can navigate between the slides either by using the NumericStepper control or via the keyboard. Additionally, it has a second State, the Index, which you can navigate to by pressing the "Index" button. The Index Sate shows you a thumbnail view of of all the loaded slides along with their titles. The transitions between slides is a simple cross-fade. If you change the presentation.xml file (eg. to create your own presentations using the application), click the "Refresh" button to reload the data.
See the slide application and view the slides for my London MMUG presentation online.
Download the source code (474kb), including the slide images and the presentation.xml.
Known issuesThere are a number of known issues with the application due to bugs in Flex Alpha 1 (this is to be expected in Alpha software and I am confident that all these issues will be fixed in future alpha/beta releases.) I'm planning on covering each of the issues in a separate blog post so that other developers working with Flex Alpha 1 will be aware of the limitations of the current release. For the time being, however, here is a brief list of the known issues with this application, along with the Flex 2 Alpha bugs that they're related to:
- When you load the application for the first time, the slides do not show up. This occurs only when testing over the Internet, not on a local machine and is due to a bug with deferred instantiation on the ViewStack component when creationPolicy is set to "queued". Workaround: Refresh the application and the slides will load.
- If you refresh the application right after it starts loading, you will get a runtime error ("Load Never Completed"). This is not a bug and this exception will not be thrown by the final release version of the Flash 8.5 player. There is also a chance that the Preloader will catch this error in future releases so that it doesn't bubble up to the browser even when using the release version of the Flash 8.5 Debug Player.
- Clicking the application is not enough to give you focus to navigate between slides in the base State using the Left and Right arrow keys. You actually have to click in a component to do so. This is a bug with listening for the KEY_UP event on the Application form.
- The application lays itself out correctly only when the window is sized equal to or larger than the initial window size of the browser (FireFox 1.5)
- Going to the Index state a second time results in a runtime error. This appears to be a bug in the State handling code in Flex Alpha 1.
- The "Return to Slides" button in the Index state is not in a ControlBar in the Panel because there is a bug that prevents a ControlBar in a Panel from displaying when used in a State based on the default state.
- If you mouse over the area where the text in the ApplicationControlBar is ("Flex 2 by Aral Balkan (flashant.org)") before the application has fully loaded, you'll get a runtime error due to a bug with the zoom effect trying to kick in before the effect target has fully loaded
- The previously-mentioned zoom effect also showcases a bug in the resize code for the ApplicationControlBar, where the background element doesn't scale with the rest of the component.
- The current size of the application is quite large (over 300kb). This is because the SWFs generated by Flex 2 in Alpha 1 are currently not optimized. There is actually a note on this in the Known Issues section of the release notes. As I understand it, optimizations will be carried and the final release should create considerably smaller SWFs.
I'll further detail each of the bugs and highlight some of the nifty new functionality in Flex 2 that I'm using in this simple application in future posts. That includes tasty morsels such as Data Binding, States, Custom Item Renderers, Behaviors/Effects and HTTPService; not to mention the many other important new developments, like the vastly improved skinning feature, that I just didn't have time to go into during my presentation.Flex 2, although currently in alpha, offers a quantum leap in ease of development. Personally, I find that working with Flex 2 makes life fun and I can't wait for the final release version. Of course, you don't have to wait and you can get up to speed with Flex 2 now by attending my Head Start Flex 2 and ActionScript 3 courses in February as part of my Hot Shots Seminar Series.