Callbacks Class To Store Your Wishes In Time

Things are much easier when they works synchronously, you just ask for what you want and thats it, but with flash you always have to count on with asynchrony. For example you are waiting on some requests to complete or 3rd party to log you on etc. The issue is, you know you want to execute something, with custom properties, but you have to do that just after some asynchronous event dispatched. E.g. you want to update status with some message, but you need to connect to facebook first. Here comes the handy Callbacks class. What it does is, it stores your wishes and executes when things are prepared.

Read the rest of this entry »

A different view on loops – listener-looping

What is the usual practice when searching / setting / operating over some list of item? I think you usually think of iterating over some list (array) or linked list etc. Well, ActionScript has to offer one more technique you maybe never tought of, lets call it listener-looping. ActionScript is event based language, that means that every EventDispatcher based classes are able to listen and dispatch events. And this fits our needs for loop alternative. Lets suggest, you do not have any list to be iterated over but you still have a chance to accomplish it by making each item listening for custom event.

Read the rest of this entry »

Quick tip: invalidating properties on bindables changed

By default, flex bindable properties fires event PropertyChangeEvent.PROPERTY_CHANGE. Sure, those events can be listened thus you can play with them. This can be useful when you have a lot of bindable properties in your classes and you do not want to make getter and setter for each just to be able to catch the moment of update:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="" layout="horizontal" 
    [Bindable] private var bVar:uint = 0;
    [Bindable] private var btnLabel:String = "";
    private function creationCompleteHandler():void
        addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, propertyChangedHandler);
    private function propertyChangedHandler(event:PropertyChangeEvent):void
        if( == "bVar")
    override protected function commitProperties():void
        btnLabel = bVar.toString();
<mx:Button click="bVar++" label="{btnLabel}"/>