Gaia Presentatie
June 6th, 2011
Op 25 mei heb ik op FLUGR een presentatie gegeven over Gaia en hoe wij Gaia binnen MediaMonks gebruiken. Het was mijn eerste presentatie, maar het was leuk om te doen. Zeker voor herhaling vatbaar.
Weak listeners are bad
September 28th, 2010The Flash Player has a problem with cleaning up memory for AS3. Storing a reference to an object blocks the Garbage Collector from disposing the object and the object will be kept in memory. That’s why a lot of developers set ‘useWeakReference’ to true when adding an event listener.
1 | addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void |
“A strong reference (the default) prevents your listener from being garbage-collected. A weak reference does not.”
I think using weak listeners is bad practice - don’t do it!
When setting a listener as weak the responsibility of the operation of your application is transfered to the Garbage Collector, which isn’t reliable at all. If and when the Garbage Collector is running is completely random[1]. You never know if or when your listeners are removed, which makes your application unreliable and unstable. Weak listeners are used by lazy developers who don’t want to take responsibility for cleaning up their own code.
Removing event listeners should always be the responsibility of the developer (or application) and not the Garbage Collector. So if you add an event listener be sure you also remove it when the object should be disposed.
There is only one exception for using weak listeners: adding listeners to the stage. Since the stage will never be disposed and the only reference to an object is the reference to the stage, there is no need for this object to exist. But still you have to remove this (weak) listener when this object should be disposed!
Temple
If you do not want to remove all listers by hand, you could use Temple Library. This toolkit has a destruction model which automatically removes all (strong) event listeners when an object is destructed and makes the object available for garbage collection. But even if the Garbage Collector isn’t running your destructed objects won’t unnecessary listen for events.
The Temple is open-source and available on GoogleCode: http://code.google.com/p/templelibrary/
[1] I know there are some tricks to force a garbage collection, but those are all unsupported. So a Flash Player update could break those tricks.
OranjePoule - De grootste WK poule van Nederland
June 7th, 2010
De WK poule van Hyves en Telesport. Voorspel de uitslagen van de wedstrijden en word de “WK Koning van Nederland”. Je kan natuurlijk ook je eigen subpoule maken en de voorspellingen van je vrienden bekijken.
De teller staat momenteel op 169.374 deelnemers en daarmee is het al ruimschoots de grootste WK poule van Nederland. Maar daar komen uiteraard nog veel meer deelnemers bij. Wil je ook mee doen? Vul dan voor vrijdagmiddag je voorspelling in, want de inschrijving stop als het WK begint!
Voor dit project heb ik de ActionScripting gedaan. Hiervoor heb ik gebruik gemaakt van Gaia en de Temple. Ook is het caching systeem ingezet en verbeterd. Voor dit project heb ik een speciale truc bedacht om ActionScript code uit SWF files te halen, waardoor deze files meer dan de helft kleiner zijn geworden. Hierover zal ik nog een blogpost wijden.
Mede door het PHP-werk van Robert Slootjes is dit project een technisch hoogstandje geworden waar ik erg trots op ben. En ondanks mijn “liefde” voor voetbal was dit een heel erg leuk project om te doen.
Bekijk het project op:
Stemkijker - VideoPlayer
June 7th, 2010
Bekijk en vergelijk de video´s van de lijsttrekkers van de politieke partijen voor de Tweede Kamer verkiezingen op 9 juni 2010 op Stemkijker.nl
Voor TalentInsite heb ik een videoplayer gemaakt voor de Stemkijker. De videoplayer is gebaseerd op de videoplayer uit de Temple en ondersteund verschillende video formaten als flv, H2.64, progressive download en RTMP streaming. De videoplayer is schaalbaar en gemakkelijk te embedden in andere websites.
De VideoPlayer van de Temple is momenteel nog niet open-source, maar zal daar binnenkort aan worden toegevoegd.
Veilig op weg - De Game
June 7th, 2010
Een autorij-spelletje voor Pearle, waarbij je mag proberen om met -8 een auto te besturen. Onderweg pak je brilletjes op en wordt het zicht beter. Maar lukt het je ook om zonder brokken de finish te halen?
Dit semi-3D spel is gemaakt zonder 3D framework, maar gewoon met de 3D feature van Flash player 10. Uiteraard wel met behulp van onze Temple Library, en Gaia voor de pagina navigatie.
Voor dit project heb ik de ActionScripting gedaan. Het design is gemaakt door Vincent van de Wetering.
Speel het spel op:
Flash: Convert a function reference to a readable string
April 23rd, 2010
If you have a function reference in Flash there is not a lot of information you can get from it. Converting the function to a string will only give you: Read the rest of this entry »
How to set MXMLC (FCSH) to English (on Windows)
March 25th, 2010If you are working in the Netherlands on a pc with MXMLC (FCSH) you probably get all your errors in Dutch, like:
“Functie heeft geen hoofdtekst.” or “Waarde van het type Function is gebruikt waar type void werd verwacht. Mogelijk ontbreken ronde haakjes () na deze functieverwijzing”.
Funny, but not very handy since most help and documentation is in English. So I wanted my errors in English. FCSH does not have any option to change the language. Changing Windows to English doesn’t change anything and setting the location to U.S. doesn’t help either. Finally we found out that setting the format to”English (United States)” will set MXMLC to English:

Unfortunately this will also change your number, currency, time and data formatting. But you can customize this back to the Dutch settings.
Temple open sourced.
March 22nd, 2010
‘Temple‘ is the name of our AS3 library we use at MediaMonks. Almost all of our AS3 projects are using it. The Temple is inspired on several 3rd party libraries like ASAPLibrary, AS3CoreLib and CaseLib, but adapted to fit our needs.
The Temple consists of several classes we use on a regular basis. They are designed for reusability and optimized for performance and memory usage. The Temple is specially designed to work with other frameworks like Gaia. The core of the Temple focuses on: debugging, destruction and memory management.
Debugging
Many classes are debuggable and have a ‘debug’ property. When this property is enabled, the object logs debug messages which allow you to see what the object is doing. All debuggable objects can be managed by the DebugManager. The DebugManager allows you to run all objects in debug mode.
All messages are logged through the Log class which is easily extended for usage by other logging applications, like Yalog and DeMonsterDebugger.
Destruction
All objects are destructible. By calling the destruct- method, the object will clear all of its data, removes all event listeners, removes itself from the display list (DisplayObjects only of course) and makes the object available for garbage collection. Destruction is recursive, so an object will also destruct all its children.
Memory Management
All Temple objects are tracked, via weak reference, in the Memory class. You can view all objects in the Memory class. This makes it possible to detect if an object’s destruct method is working correctly.
More
We also added many nice utility classes for the initial release of Temple, however there is a lot more to come. Since we are keen on stable, neat, and well documented code we are initially only releasing the core of the Temple library. This code has been used and tested and has proven to fit our requirements. There is a lot more we are planning to release soon, like UI components (buttons, form components, video player), loaders (CacheLoader, ImageLoader) and behaviors.
The Temple can be downloaded from Google code and the documentation can be viewed online.
For updates follow us at Twitter.
The Temple is released under the GNU General Public License which allows you to use, extend or modify the code to whatever you want.
Cache and preload Gaia pages
January 25th, 2010
I use Gaia a lot. I think it’s a great and powerful framework to create page-based Flash sites. But there is a problem: Gaia creates a SWF for every page. And every time you visit a page, the SWF is loaded again. Even if you already visited that page. Also it is not possible to preload pages you are not visiting.
To make page caching and page preloading possible, I have created the ‘CacheLoader‘ and ‘CacheURLLoader‘ classes. Both classes make use of the ‘LoaderCache‘ to cache the SWF files used by Gaia. Just add these 3 classes to your project and you only have to adapt 2 Gaia classes to enable this feature: Read the rest of this entry »









