One of the most common data structure in Flash is Array, which provides a fast way to construct a list of data items with compact memory cost. This data structure is working fine and rather fast, except for some operations, for example, insert / remove items randomly (splice) or pushing things to the beginning of the Arrays (unshift). Because of the compact memory implementation, all the existed items after the insert position will need to be migrated. With o(n) complexity, operated time goes up linearly with the number of items. And it’s just the same for Vector, although Vector is way faster than Array as there are no dense checking and converting between Dense Array & Hash Table (there are more reasons ? ). In short : Array is slowing down by items migration

A rather popular solution is using Linked List – either double or single. Linked list has ability to add and remove items very fast at an arbitrary position as no item is being migrated. Double linked list cost more memory (~ 1.5x ) and a bit slower than single Linked List (which, consume 2x more memory than Array) but it allows traversing in both direction. For some operations, the doubles run faster (~ 2x faster) than single ones. But as we won’t have random access to items by numeric indexes like Arrays, it’s really slow if we need to skip forward / backward to get to some random position. In short : Linked List is slowed down by skipping to specific position  Continue reading


After using Gaia for a long time with numerous websites built, i can tell you that completely like it as the workflow is simplified so much, i really love the scaffolding, assets managements, contextMenu, event hijacking, routing, assetPath, tracking, binding expression, the complete integration of SWFAddress, SEO … everything ! But that’s not to say there are no more room to get improved. Let’s dig in for more details !

    Continue reading


After working with AS3 and loving it for several years, i found that besides things i really like like package’s function, private classes, Function variable, getDefinitionByName … there are many other downside of the language design

Actionscript 3, although is better than javascript (more OOP, strong typing, optional arguments, namespace …) but still misses some cool features that Haxe (and others, like C#, C++ ) has

  • Overloading functions / operators (Polymorphism)
  • Type interference
  • Enumeration
  • Inlining
  • Type definition

Continue reading


While building a basic Event system is not a big problem in AS3, take into accounts all special cases can be very troublesome. Some of the most significant ones are

Priority – how can we handle events more effective ? the numbering sorting priority system seems to be ugly, non dense and can not ensure things to work correctly. What if a component thinks that it should be call first, or call last, then another one thinks that, too ?

Cancelable – it will be based on the priority, how we can ensure that our callbacks would stop the dispatching stream before any other guys get updated. Should we have some kind of internal dispatching / callback to update internal things first ?

Recursive – there are case when we click something, active it, then on the handler, after doing something, we set active back to some other value, the event system may not be working as expected ? May be we should add some variable and check if it’s dispatching, if yes, just defer new dispatchings till next frame

Loop back – while we are trying to use some set of components that are someway bind to another, changing one can dispatch an event to change another, which can be looped back to change the dispatch source, which can cause an unstoppable loop for normal case, and blink loop for defer dispatching case (defer dispatching won’t solve this). We can add some kind of changes detection before dispatching, but it can be not accuracy after some data conversion, particularly for Numbers where we need to take round off errors into account.

Validation – before sending update to all the registered listeners, we may need to validate the value to ensure the changed value is valid. How can we do that? What if there are not only one validators out there, and then will their priority affects ?

Update skipping – While it’s best practice trying to update the View based on Model event, there are some case that updating the view directly boost the performance dramatically. How we handle this case ? can we add some kind of dispatching target (not the Dispatching Object itself) so we can check and skip / only update necessary things while getting the event back from Model ?