flex event propagation, metadata, view states
DESCRIPTION
TRANSCRIPT
![Page 1: Flex Event Propagation, Metadata, View states](https://reader035.vdocuments.net/reader035/viewer/2022081602/546bb359af795900458b54ed/html5/thumbnails/1.jpg)
Flex Training Day 4:Flex Events, Metadata & View States
![Page 2: Flex Event Propagation, Metadata, View states](https://reader035.vdocuments.net/reader035/viewer/2022081602/546bb359af795900458b54ed/html5/thumbnails/2.jpg)
What are Events? Events propagation in Flex Custom Events Metadata tags View States in Flex
![Page 3: Flex Event Propagation, Metadata, View states](https://reader035.vdocuments.net/reader035/viewer/2022081602/546bb359af795900458b54ed/html5/thumbnails/3.jpg)
Events let us know when something happens within an application
Any user or system interaction with your application can generate events
Components generate and dispatch events and consume (listen to) other events.
![Page 4: Flex Event Propagation, Metadata, View states](https://reader035.vdocuments.net/reader035/viewer/2022081602/546bb359af795900458b54ed/html5/thumbnails/4.jpg)
An event system consists of 3 main entities: dispatchers, listeners, and event objects. Event dispatchers are objects that dispatch events to objects that are registered as listeners
![Page 5: Flex Event Propagation, Metadata, View states](https://reader035.vdocuments.net/reader035/viewer/2022081602/546bb359af795900458b54ed/html5/thumbnails/5.jpg)
Almost all event classes extend the flash.events.Event class
EventDispatcher gives the classes a capability to participate fully in the event model.
All DisplayList items extend from EventDispatcher
For non-visual components we can also implement the IEventDispatcher interface
![Page 6: Flex Event Propagation, Metadata, View states](https://reader035.vdocuments.net/reader035/viewer/2022081602/546bb359af795900458b54ed/html5/thumbnails/6.jpg)
When events are triggered, there are three phases in which Flex checks whether there are event listeners. These phases occur in the following order:•CapturingCapturing•TargetingTargeting•BubblingBubbling
‘target’ property refers to the dispatcher of the event. The ’currentTarget’ property refers to the current node that is being examined for event listeners.
![Page 7: Flex Event Propagation, Metadata, View states](https://reader035.vdocuments.net/reader035/viewer/2022081602/546bb359af795900458b54ed/html5/thumbnails/7.jpg)
During any phase, you can stop the traversal of the display list by calling one of the following methods on the Event object:
stopPropagation() stopImmediatePropagation()
Both methods prevents the Event object from moving on to the next node,With the difference that
stopImmediatePropagation() does not allow any other event listeners on the current node to execute
![Page 8: Flex Event Propagation, Metadata, View states](https://reader035.vdocuments.net/reader035/viewer/2022081602/546bb359af795900458b54ed/html5/thumbnails/8.jpg)
04/08/23 8
![Page 9: Flex Event Propagation, Metadata, View states](https://reader035.vdocuments.net/reader035/viewer/2022081602/546bb359af795900458b54ed/html5/thumbnails/9.jpg)
Metadata tag is the information to the Flex compiler that describes how components are used in a Flex application
The metadata tags define component attributes, data binding properties, events, and other properties of the component. Flex interprets these statements during compilation; they are never interpreted during run time.
Metadata statements are associated with a class declaration, an individual data field, or a method.
04/08/23 9
![Page 10: Flex Event Propagation, Metadata, View states](https://reader035.vdocuments.net/reader035/viewer/2022081602/546bb359af795900458b54ed/html5/thumbnails/10.jpg)
04/08/23 10
![Page 11: Flex Event Propagation, Metadata, View states](https://reader035.vdocuments.net/reader035/viewer/2022081602/546bb359af795900458b54ed/html5/thumbnails/11.jpg)
What are view states?In many rich Internet
applications, the interface changes based on the task the user is performing. A simple example is an image that changes when the user rolls the mouse over it. View states let you easily implement such applications.
A.Default view state B.Rich view state
![Page 12: Flex Event Propagation, Metadata, View states](https://reader035.vdocuments.net/reader035/viewer/2022081602/546bb359af795900458b54ed/html5/thumbnails/12.jpg)
A.Modified title of Panel container B.New form item C.Modified label of Button control D.New LinkButton control
•Item Creation Policy – deferred or immediate
![Page 13: Flex Event Propagation, Metadata, View states](https://reader035.vdocuments.net/reader035/viewer/2022081602/546bb359af795900458b54ed/html5/thumbnails/13.jpg)
![Page 14: Flex Event Propagation, Metadata, View states](https://reader035.vdocuments.net/reader035/viewer/2022081602/546bb359af795900458b54ed/html5/thumbnails/14.jpg)