| By Yakov Fain | Article Rating: |
|
| August 3, 2006 11:15 AM EDT | Reads: |
29,578 |
I did a mini research on what’s happening under the hood when Flash Player 9 loads and starts a Flex 2 application. Since Flex 2 is still pretty young, there is not too many resources available, so I’d appreciate any feedback.
The SystemManager is a main manager that controls the application window, creates and parents the Application instance, popups, cursors, manages the classes in the ApplicationDomain, and more. The SystemManager is the first class that is instantiated by Flash Player for your application. It stores the size and position of the main application window, keeps track of its children, such as floating popups and modal windows. Using the SystemManager you can access embedded fonts, styles and the document object. SystemManager also controls application domains, which are used to partition classes by security domains (see description of the ApplicationDomain class in Flex Language Reference).
If you’ll be developing custom visual components (descendents of the UIComponent class), keep in mind that initially such components are not connected to any display list and the SystemManager=null. Only after the first call of the addChild() a SystemManager will be assigned to them. You should not access SystemManager from the constructor of you component, because it can still be null.
In general, when the Application object is created, it goes through the following steps:
1. Instantiation of the Application object begins.
2. Initializes the Application.systemManager property
3. The Application dispatches the preinitialize eventat the beginning of the initialization process.
4. The method createChildren() is called on the applicatoin. At this point each of the application’s components is being constructed, and each component’s createChildren() will be also called.
5. The Application dispatches the initialize event, which indicates that all application’s components have been initialized.
6. The creationComplete event is being dispatched
7. The Application object is added to the display list.
8. The applicationComplete event is being dispatched.
In most cases, you should use the mxml tag <mx:Application> for creation of the application object, but if you need to write it in ActionScript, it is not recommended creating components in constructor - use createChildren() for this (for performance reasons).
As opposed to Flash movies that consist of multiple frames being displayed over a timeline, Flex SWF files have only two frames. The SystemManager, Preloader, DownloadProgressBar and a handful of other helper classes live in the first frame. The rest of the Flex framework, your application code and embedded assets like fonts and images reside in the second frame. When Flash Player initially starts downloading your SWF, as soon as enough bytes come for the first frame, it instantiates a SystemManager, which creates a Preloader, which in turn creates a DownloadProgressBar and these two objects are watching the rest of the byte streaming-in process. What all bytes for the first frame are in, SystemManager sends the enterFrame for the second frame, and then renders other events. Eventually, the Application object dispatches the applicationComplete event.
You may say, why do I need to know what’s happening before my application starts? This knowledge may become quite handy. For example, you can create a fading splash screen with the image of your choice by substituting the standard Flex Preloader and the DownloadProgressBar objects with the custom ones. Ted Patrick from Adobe has provided a nice sample application that does exactly this: displays a splash screen using an image from a from a .gif file. While a your splash screen is displayed, you can download some other system resources and/or libraries.
The application tag of this sample looks pretty straightforward:
<mx:Application xmlns:mx=http://www.adobe.com/2006/mxml
preloader="preload.CustomPreloader" >
Download the code of this application and you’ll see that the classes CustomPreloader that extends the DownloadProgressBar and a helper WelcomeScreen that loads the image and fades it away are also pretty small.
addCallBack(), the registered function in Flash Player can be called by JavaScript or ActiveX code in the container.One more. Your Application may need to load another application(s) from an SWF. If you have to do it in ActionScript, you can use the class SWFLoader from the applicationComplete event.
The most important feature of the Flex 2 is that it’s an open and extendable framework. I’m accustomed to being in complete control with Java, and Flex does not tie your hands either. On the same note, since Flex Builder is built on the Eclipse platform, it lets you extend its functionality by creating your own plugins. For example, here is a To-Do/FixMe plugin.
That's all...for now.
Update: after this article has been published, Farata Systems has created a logon component to be used in Preloader.
Published August 3, 2006 Reads 29,578
Copyright © 2006 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Yakov Fain
Yakov Fain is a Managing Director of Farata Systems, consulting, training and product company. He has authored several Java books, dozens of technical articles. SYS-CON Books released his latest co-authored book , Rich Internet Applications with Adobe Flex and Java: Secrets of the Masters in Spring 2007. Sun Microsystems has nominated and awarded Yakov with the title Java Champion. He leads the Princeton Java Users Group. He is an Adobe Certified Flex Instructor. Currently Yakov works on the book for O'Reilly "Enterprise Application Development with Flex". He twits at twitter.com/yfain.
![]() |
JDJ News Desk 08/03/06 09:19:00 AM EDT | |||
The main manager that controls the application window, creates and parents the Application instance, popups, cursors, manages the classes in the ApplicationDomain, and more. The SystemManager is the first class that is instantiated by Flash Player for your application. It stores the size and position of the main application window, keeps track of its children, such as floating popups and modal windows. |
||||
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Adobe Unveils LiveCycle Enterprise Suite 2 for Deployment in the Cloud
- Adobe Flex Developer Earns $100K in New York City
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Ph.D. in Twitter Anyone?
- Eolas Sues the Internet
- Adobe LiveCycle Enterprise Suite 2 for Cloud Computing
- Adobe Betas Target RIAs and Cloud Computing
- Special Report on the Emerging Cloud Computing Trend
- Adobe Cans Another 9% of its Workforce
- My Thoughts on Ulitzer
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Ulitzer Live! New Media Conference & Expo
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Eval JavaScript in a Global Context
- Fig Leaf Software to Exhibit at Government IT Conference & Expo
- Cloud Executives Feature on Cloud Computing Expo Power Panel
- Software Flexibility in the Cloud - Part 4 of 5
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Is Microsoft as Free as Open Source?
- Adobe Reader Sued
- Adobe Unveils LiveCycle Enterprise Suite 2 for Deployment in the Cloud
- Where Are RIA Technologies Headed in 2008?
- Cover Story: How to Increase the Frame Rates of Your Flash Movies
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Your First Adobe Flex Application with a ColdFusion Backend
- Adobe Flex 2: Advanced DataGrid
- i-Technology Blog: Death-Knell For "Rich Media? Hardly!
- Adobe/Macromedia - Microsoft, Look Out!
- How To Create a Photo Slide Show ...
- Adobe Flex Interface Customization - Themes, Styles, Skins
- Personal Branding Checklist
- Has the Technology Bounceback Begun?
- "Real-World Flex" by Adobe's Christophe Coenraets





































