Friday, December 18, 2009

Event.bubbles, Event.cancelable, and Event.currentTarget

Perhaps some of you may not know this, but event-bubbling in Actionscript3.0 is way cool and well worth your attention. So read on.
With event-bubbling you can let one Event subsequently call on every ancestor (containers of containers of etc.) of the DisplayObject that originally dispatched the Event, all the way up to the surface (read: Stage), hence the name 'bubbling'.Perhaps noteworthy is that bubbling for an Event instance is disabled by default, and can only be activated by setting the bubbling parameter in the Event constructor.
Although the documentation doesn't seem to make it all too apparent, event-bubbling is actually the reason why the Event class has a currentTarget property (as well as a target property).So what is the use of Event.currentTarget? While the target property will always have its value set to the DisplayObject that originally dispatched the Event, the currentTarget property always points to the DisplayObject that the event is currently processing (i.e. bubbling at).
Find out more here actual source

Thursday, December 17, 2009

Manual Data Binding in Flex

You need to set up data binding manually. This allows you to do much more complicated and powerful things with data binding

Typically, you set up data binding using the simple Flex data binding syntax, like this:

Assuming the property is bindable, this will automatically change the label every time the "someProperty" property changes.But what if you want to do something more complicated, like execute a block of code in response to a property changing? You can't use the simple Flex data binding syntax. Rather, you have to set data binding up manually which you can do with the mx.binding.utils.ChangeWatcher class like this:
ChangeWatcher.watch(someObject, "someProperty", onPropertyChange);
This will ensure that your onPropertyChange function will get called every time the "someProperty" property changes.This is especially useful and powerful when using the Cairngorm Flex framework.

Will any event be dispatched when the user closes the browser window

Detailed explanation
No event will be dispatched by Flash Player or Flex framework when the user is closing the window. Your application can still be notified via JavaScript using ExternalInterface API.All you have to do is have a JavaScript function which will be invoked when the HTML page is unloaded. In this JavaScript function you can invoke a function in Flex to perform your desired operation.
Find the example code here :

Freelance