Tuesday, November 18, 2008

Deep Dive into the Flex 3 Framework

A deep dive particularly into data binding, styles, collections and the system manager.

Data binding
Mark object and properties as bindable
In the background, events are wired to update the object when the value object changes
In MXML, it will be bindable if it has the id set
Two formats:
If not specified, the event type is PropertyChangedEvent
More efficient to use custom event types, but you have to dispatch it yourself
You can bind a function, but you have to create a custom event and dispatch it yourself
If bound, the function is recalled any time any of the bound arguments to it changes
You can bind to expressions, and you can have chained bindings
If you have a lot of bindable properties, the custom event types ensure that the object only gets the messages it cares about

Styles are inheritable
StyleManger class manages this
Managed through proto-chaining
getStyle (cheap) / setStyle (expensive)
getStyleDeclaration/setStyleDeclaration (used to manipulate styles on the fly)
registerColorName (used to assign aliases to hexadecimal color values, e.g., “red”)
load styles from SWF file at runtime

Used to get data in a variety of formats into a variety of view controls
Provide sort, filter operations
IList (list) / ICollectionView (hierarchical)
Sort < - takes a sortObject
Abstracts the data format
Use getitemat rather that [] because of Flash Player bug
Set sort objects (a series of sortFields) and then call refresh
Call validateNow after changing dataProvider if you need to work with data right away
This is an expensive operation
Mark as bindable and call itemchanged

Owns the root of the SWF
First class instantiated
SWF compiled by Flex is 2 frame

Frame 1
System Manager
Helper Classes

Frame 2
Flex Framework
Application Code
Runtime Shared Libraries (RSL)

System Manager
Browser resize events
Detects if assets are embedded
Overload preloader
Get reference to root and manipulate

No comments: