Skip to content

Instantly share code, notes, and snippets.

@mikecann
Created August 13, 2010 12:56
Show Gist options
  • Save mikecann/522826 to your computer and use it in GitHub Desktop.
Save mikecann/522826 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="onCreationComplete(event)">
<fx:Script>
<![CDATA[
import mx.controls.List;
import mx.events.FlexEvent;
protected var _listeners : Dictionary;
protected function onCreationComplete(event:FlexEvent):void
{
_listeners = new Dictionary();
}
protected function onCheckClicked(event:MouseEvent):void
{
var o : Object = {};
o.dispatch = function() : void { trace("dispatched"); }
_listeners[o.dispatch] = 0;
}
protected function onRunGCClicked(event:MouseEvent):void
{
// Force a GC
try
{
new LocalConnection().connect('foo');
new LocalConnection().connect('foo');
}
catch (e:*) {}
}
protected function onDispatchClicked(event:MouseEvent):void
{
for (var listener : * in _listeners)
{
listener();
}
}
]]>
</fx:Script>
<s:VGroup width="100%" height="100%" horizontalAlign="center" verticalAlign="middle">
<s:Button label="Add Listener" click="onCheckClicked(event)" />
<s:Button label="Run GC" click="onRunGCClicked(event)" />
<s:Button label="Dispatch" click="onDispatchClicked(event)" />
</s:VGroup>
</s:WindowedApplication>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment