<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Method Closure Owner (arguments.caller)</title>
	<atom:link href="http://blog.betabong.com/2009/03/26/method-closure-owner/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.betabong.com/2009/03/26/method-closure-owner/</link>
	<description></description>
	<lastBuildDate>Sun, 22 Jan 2012 17:41:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Steven Vachon</title>
		<link>http://blog.betabong.com/2009/03/26/method-closure-owner/comment-page-1/#comment-190</link>
		<dc:creator>Steven Vachon</dc:creator>
		<pubDate>Fri, 17 Dec 2010 22:47:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.betabong.com/?p=214#comment-190</guid>
		<description>True, but it&#039;s great for debugging

And yeah, oops, heheh... only needed this once so far and knowing the calling class was enough :)</description>
		<content:encoded><![CDATA[<p>True, but it&#8217;s great for debugging</p>
<p>And yeah, oops, heheh&#8230; only needed this once so far and knowing the calling class was enough :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: betabong</title>
		<link>http://blog.betabong.com/2009/03/26/method-closure-owner/comment-page-1/#comment-175</link>
		<dc:creator>betabong</dc:creator>
		<pubDate>Sun, 21 Nov 2010 10:02:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.betabong.com/?p=214#comment-175</guid>
		<description>This is indeed very interesting. Thing is: all you get is a string information about which class and which method was calling. But not the calling method itself. And I don&#039;t see how you could derive this reference from it. Still, nice :-)

(it&#039;s index 2 by the way:)
&lt;pre&gt;
trace((new Error()).getStackTrace().split(’\n’)[2]);
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>This is indeed very interesting. Thing is: all you get is a string information about which class and which method was calling. But not the calling method itself. And I don&#8217;t see how you could derive this reference from it. Still, nice :-)</p>
<p>(it&#8217;s index 2 by the way:)</p>
<pre>
trace((new Error()).getStackTrace().split(’\n’)[2]);
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven Vachon</title>
		<link>http://blog.betabong.com/2009/03/26/method-closure-owner/comment-page-1/#comment-174</link>
		<dc:creator>Steven Vachon</dc:creator>
		<pubDate>Sun, 21 Nov 2010 09:39:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.betabong.com/?p=214#comment-174</guid>
		<description>I realize that this post is over a year old, but I was looking for this very thing, and I found this on a website just now:

// the 3rd line is the equivalent of &quot;attributes.caller&quot;
trace((new Error()).getStackTrace().split(&#039;\n&#039;)[3]);</description>
		<content:encoded><![CDATA[<p>I realize that this post is over a year old, but I was looking for this very thing, and I found this on a website just now:</p>
<p>// the 3rd line is the equivalent of &#8220;attributes.caller&#8221;<br />
trace((new Error()).getStackTrace().split(&#8216;\n&#8217;)[3]);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lance</title>
		<link>http://blog.betabong.com/2009/03/26/method-closure-owner/comment-page-1/#comment-63</link>
		<dc:creator>Lance</dc:creator>
		<pubDate>Mon, 24 Aug 2009 18:12:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.betabong.com/?p=214#comment-63</guid>
		<description>If only dynamic classes weren&#039;t bad practice in Actionscript :)

Those properties were dynamically defined.</description>
		<content:encoded><![CDATA[<p>If only dynamic classes weren&#8217;t bad practice in Actionscript :)</p>
<p>Those properties were dynamically defined.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lance</title>
		<link>http://blog.betabong.com/2009/03/26/method-closure-owner/comment-page-1/#comment-62</link>
		<dc:creator>Lance</dc:creator>
		<pubDate>Mon, 24 Aug 2009 18:11:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.betabong.com/?p=214#comment-62</guid>
		<description>For sure Betabong, I totally agree.  I&#039;m coming from a Ruby background and there&#039;s just so much cool stuff left out in compiled languages, like blocks/yields for instance, and modules, so I find myself trying to recreate those core language features in actionscript for 1) keeping code lean so I don&#039;t repeat myself, and 2) making it intuitive to do hardcore things.  They should go into the core language:)

Anyway, thanks a lot for the great response.  When I get some time I&#039;ll have to check out how garbage collection would work exactly in this case.  I&#039;m thinking about creating an EventUtil class that does what your BetterEventDispatcher does, so I can use it here and there.

- Lance</description>
		<content:encoded><![CDATA[<p>For sure Betabong, I totally agree.  I&#8217;m coming from a Ruby background and there&#8217;s just so much cool stuff left out in compiled languages, like blocks/yields for instance, and modules, so I find myself trying to recreate those core language features in actionscript for 1) keeping code lean so I don&#8217;t repeat myself, and 2) making it intuitive to do hardcore things.  They should go into the core language:)</p>
<p>Anyway, thanks a lot for the great response.  When I get some time I&#8217;ll have to check out how garbage collection would work exactly in this case.  I&#8217;m thinking about creating an EventUtil class that does what your BetterEventDispatcher does, so I can use it here and there.</p>
<p>- Lance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: betabong</title>
		<link>http://blog.betabong.com/2009/03/26/method-closure-owner/comment-page-1/#comment-61</link>
		<dc:creator>betabong</dc:creator>
		<pubDate>Mon, 24 Aug 2009 09:14:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.betabong.com/?p=214#comment-61</guid>
		<description>Hey Lance, interesting post! I&#039;m still not totally sure about the reason for these extra handler classes - may be because you haven&#039;t posted all the code? 

For example SmartEvent: Why is it dynamic? Are targetObjet, target, property, oldValue defined somewhere, or are those dynamic properties? It&#039;s generally a good idea to avoid dynamic classes for several reasons (speed and control), so I don&#039;t really see the big benefit here.

Then there&#039;s several potential problems with your &quot;shadow&quot; classes here, especially with EventHandler. As it seems to me neither its instance nor its target object will be garbage collected, resulting not only in memory leaks but also in potential misbehaviour (though I&#039;m not totally sure about both, I&#039;d have to take more time to think this trough thouroughly). It also seems that you won&#039;t have any more possibility to get to EventHandler once you&#039;ve created it: So how would you remove a listener at a later time?

As for me I try to keep as much control as I can by keeping things as basic as possible:

- never reference an object in another one if not absolutely necessary. And if I have to do so: make sure the reference will be nulled on destruction.

- if you have instances listen to dispatchers, make sure you&#039;ll unlisten on destruction - or/and use weak listeners if possible

Still, I also use &quot;helpers&quot; sometimes, especially for bigger stuff. For once I subclassed EventDispatcher into BetterEventDispatcher which can keep track of listeners, providing things I&#039;d wish for all event dispatcher, especially the method removeAllListeners. And then I&#039;d subclass from that one instead of EventDispatcher.

And for my framework classes I&#039;ve added listenTo and unlistenTo methods for the core class. Here also I keep track of what instances I&#039;m listening to (opposed to the BetterEventDispatcher who keeps track of who&#039;s listening to me). So on destruction I can call unlistenToAll() and I&#039;m fine with the garbage collector if I&#039;ve always gone through those two methods listenTo and unlistenTo.

May be I&#039;m gonna write a post about this one time. Still in my opinion it&#039;s too much work for us to do: These kind of things should be in the core language, with a better event framework and the addition of destructors.</description>
		<content:encoded><![CDATA[<p>Hey Lance, interesting post! I&#8217;m still not totally sure about the reason for these extra handler classes &#8211; may be because you haven&#8217;t posted all the code? </p>
<p>For example SmartEvent: Why is it dynamic? Are targetObjet, target, property, oldValue defined somewhere, or are those dynamic properties? It&#8217;s generally a good idea to avoid dynamic classes for several reasons (speed and control), so I don&#8217;t really see the big benefit here.</p>
<p>Then there&#8217;s several potential problems with your &#8220;shadow&#8221; classes here, especially with EventHandler. As it seems to me neither its instance nor its target object will be garbage collected, resulting not only in memory leaks but also in potential misbehaviour (though I&#8217;m not totally sure about both, I&#8217;d have to take more time to think this trough thouroughly). It also seems that you won&#8217;t have any more possibility to get to EventHandler once you&#8217;ve created it: So how would you remove a listener at a later time?</p>
<p>As for me I try to keep as much control as I can by keeping things as basic as possible:</p>
<p>- never reference an object in another one if not absolutely necessary. And if I have to do so: make sure the reference will be nulled on destruction.</p>
<p>- if you have instances listen to dispatchers, make sure you&#8217;ll unlisten on destruction &#8211; or/and use weak listeners if possible</p>
<p>Still, I also use &#8220;helpers&#8221; sometimes, especially for bigger stuff. For once I subclassed EventDispatcher into BetterEventDispatcher which can keep track of listeners, providing things I&#8217;d wish for all event dispatcher, especially the method removeAllListeners. And then I&#8217;d subclass from that one instead of EventDispatcher.</p>
<p>And for my framework classes I&#8217;ve added listenTo and unlistenTo methods for the core class. Here also I keep track of what instances I&#8217;m listening to (opposed to the BetterEventDispatcher who keeps track of who&#8217;s listening to me). So on destruction I can call unlistenToAll() and I&#8217;m fine with the garbage collector if I&#8217;ve always gone through those two methods listenTo and unlistenTo.</p>
<p>May be I&#8217;m gonna write a post about this one time. Still in my opinion it&#8217;s too much work for us to do: These kind of things should be in the core language, with a better event framework and the addition of destructors.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lance</title>
		<link>http://blog.betabong.com/2009/03/26/method-closure-owner/comment-page-1/#comment-60</link>
		<dc:creator>Lance</dc:creator>
		<pubDate>Mon, 24 Aug 2009 00:14:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.betabong.com/?p=214#comment-60</guid>
		<description>Hey man,

These posts on Method Closures have been amazing... nothing like it out there.  I have a question/case, what do you think...

I have a &#039;public static EventHandler&#039; class, which creates an EventHandler object, which allows you to pass arguments to the event handler, like so:

&lt;pre lang=&quot;actionscript&quot;&gt;
var handler:Function = EventHandler.handler(theRealHandler, [arg1, arg2], true);
target.addEventListener(&quot;something&quot;, handler);

public function theRealHandler(event:Event, arg1:*, arg2:*):void ...
&lt;/pre&gt;

...where the last parameter, &quot;true&quot;, says you also want the event.

The first question is, if I declare that &quot;var handler&quot; inside of a method, where is it stored?  Because the EventHandler static class created a new object, and passed the result to the handler inside that method, it seems like a loop and I don&#039;t know well enough how things are stored in Flash to see how that would be garbage collected (the handler, and the EventHandler object).  The EventHandler object looks like this:

&lt;pre lang=&quot;actionscript&quot;&gt;
class EventHandler {

	public var args:Array;
	public var eventHandler:Function;
	public var includeEvent:Boolean;
	
	public function EventHandler(eventHandler:Function, arguments:Array = null, includeEvent:Boolean = false) {
		this.eventHandler = eventHandler;
		this.args = arguments;
		this.includeEvent = includeEvent;
	}
	
	public function handleEvent(event:*):void {
		var result:Array = args.concat();
		if (includeEvent) result.splice(0, 0, event); // add event to beginning of array
		eventHandler.apply(null, result);
	}

	public static function handler(eventHandler:Function, arguments:Array = null, includeEvent:Boolean = false):Function {
		return new EventHandler(eventHandler, arguments, includeEvent).handleEvent;
	}
}
&lt;/pre&gt;

...Second question is in regards to making this easy to read and more customizable.  In order to make code clean, I created another object, SmartEvent.  This is all the EventHandler without the static methods.  In addition, it&#039;s a dynamic class, so you can pass through any properties in the event, and reset them whenever.  Looks like this:

&lt;pre lang=&quot;actionscript&quot;&gt;
var event:SmartEvent(realHandler);
event.arg1 = value;
event.arg2 = value2;
target.addEventListener(&quot;something&quot;, event.handler);

...where &quot;handler&quot; is the internal handler from the EventHandler class, and it just passes the SmartEvent to the &quot;realHandler&quot;.

So SmartEvent looks like this:

public dynamic class SmartEvent extends flash.events.Event
{
	public var originalEvent:flash.events.Event;
	
	public var eventHandler:Function;
	
	public function SmartEvent(eventHandler:Function) {
		super();
		this.eventHandler = eventHandler;
	}
	
	public function handler(event:Event):void {
		originalEvent = event;
		eventHandler(this);
	}
}
&lt;/pre&gt;

...Then you can reset variables (aka &#039;arguments&#039;) on your SmartEvent every time it is handled.  This is basically an adapter for a PropertyChangeEvent when you don&#039;t know the property, source, or target (from Flex binding), and can be used like a Scope object in Mate.  So in the &quot;realHandler&quot;, you could do this:

&lt;pre lang=&quot;actionscript&quot;&gt;
public function realHandler(event:SmartEvent):void {
	var oldValue:* = event.oldValue; // defined in some method
	var target:Object = event.targetObject;
	var source:Object = event.target;
	var property:String = event.property; // defined in some method
	var newValue:* = source[property];
	if (oldValue != newValue) {
		target[property] = newValue;
		event.oldValue = newValue; // reset oldValue, so the next time through its different
	}
}
&lt;/pre&gt;

...I made all this from reading your posts, but I&#039;m not sure how the garbage collection because everything&#039;s referencing everything else.  It makes a lot more possible in event handling though!  Any ideas if this this is okay practice or how to make it better?

Thanks man!
Lance</description>
		<content:encoded><![CDATA[<p>Hey man,</p>
<p>These posts on Method Closures have been amazing&#8230; nothing like it out there.  I have a question/case, what do you think&#8230;</p>
<p>I have a &#8216;public static EventHandler&#8217; class, which creates an EventHandler object, which allows you to pass arguments to the event handler, like so:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> handler:<span style="color: #000000; font-weight: bold;">Function</span> = EventHandler.<span style="color: #006600;">handler</span><span style="color: #66cc66;">&#40;</span>theRealHandler, <span style="color: #66cc66;">&#91;</span>arg1, arg2<span style="color: #66cc66;">&#93;</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">target</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;something&quot;</span>, handler<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> theRealHandler<span style="color: #66cc66;">&#40;</span>event:Event, arg1:<span style="color: #66cc66;">*</span>, arg2:<span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> ...</pre></div></div>

<p>&#8230;where the last parameter, &#8220;true&#8221;, says you also want the event.</p>
<p>The first question is, if I declare that &#8220;var handler&#8221; inside of a method, where is it stored?  Because the EventHandler static class created a new object, and passed the result to the handler inside that method, it seems like a loop and I don&#8217;t know well enough how things are stored in Flash to see how that would be garbage collected (the handler, and the EventHandler object).  The EventHandler object looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> EventHandler <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> args:<span style="color: #0066CC;">Array</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> eventHandler:<span style="color: #000000; font-weight: bold;">Function</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> includeEvent:<span style="color: #0066CC;">Boolean</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> EventHandler<span style="color: #66cc66;">&#40;</span>eventHandler:<span style="color: #000000; font-weight: bold;">Function</span>, <span style="color: #0066CC;">arguments</span>:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">null</span>, includeEvent:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">this</span>.<span style="color: #006600;">eventHandler</span> = eventHandler;
		<span style="color: #0066CC;">this</span>.<span style="color: #006600;">args</span> = <span style="color: #0066CC;">arguments</span>;
		<span style="color: #0066CC;">this</span>.<span style="color: #006600;">includeEvent</span> = includeEvent;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> handleEvent<span style="color: #66cc66;">&#40;</span>event:<span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> result:<span style="color: #0066CC;">Array</span> = args.<span style="color: #0066CC;">concat</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>includeEvent<span style="color: #66cc66;">&#41;</span> result.<span style="color: #0066CC;">splice</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, event<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// add event to beginning of array</span>
		eventHandler.<span style="color: #0066CC;">apply</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">null</span>, result<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> handler<span style="color: #66cc66;">&#40;</span>eventHandler:<span style="color: #000000; font-weight: bold;">Function</span>, <span style="color: #0066CC;">arguments</span>:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">null</span>, includeEvent:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #000000; font-weight: bold;">Function</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> EventHandler<span style="color: #66cc66;">&#40;</span>eventHandler, <span style="color: #0066CC;">arguments</span>, includeEvent<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">handleEvent</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>&#8230;Second question is in regards to making this easy to read and more customizable.  In order to make code clean, I created another object, SmartEvent.  This is all the EventHandler without the static methods.  In addition, it&#8217;s a dynamic class, so you can pass through any properties in the event, and reset them whenever.  Looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> event:SmartEvent<span style="color: #66cc66;">&#40;</span>realHandler<span style="color: #66cc66;">&#41;</span>;
event.<span style="color: #006600;">arg1</span> = value;
event.<span style="color: #006600;">arg2</span> = value2;
<span style="color: #0066CC;">target</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;something&quot;</span>, event.<span style="color: #006600;">handler</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
...<span style="color: #006600;">where</span> <span style="color: #ff0000;">&quot;handler&quot;</span> is the internal handler from the EventHandler <span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #0066CC;">and</span> it just passes the SmartEvent to the <span style="color: #ff0000;">&quot;realHandler&quot;</span>.
&nbsp;
<span style="color: #006600;">So</span> SmartEvent looks like <span style="color: #0066CC;">this</span>:
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">dynamic</span> <span style="color: #000000; font-weight: bold;">class</span> SmartEvent <span style="color: #0066CC;">extends</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> originalEvent:flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> eventHandler:<span style="color: #000000; font-weight: bold;">Function</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> SmartEvent<span style="color: #66cc66;">&#40;</span>eventHandler:<span style="color: #000000; font-weight: bold;">Function</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">this</span>.<span style="color: #006600;">eventHandler</span> = eventHandler;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> handler<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
		originalEvent = event;
		eventHandler<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>&#8230;Then you can reset variables (aka &#8216;arguments&#8217;) on your SmartEvent every time it is handled.  This is basically an adapter for a PropertyChangeEvent when you don&#8217;t know the property, source, or target (from Flex binding), and can be used like a Scope object in Mate.  So in the &#8220;realHandler&#8221;, you could do this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> realHandler<span style="color: #66cc66;">&#40;</span>event:SmartEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> oldValue:<span style="color: #66cc66;">*</span> = event.<span style="color: #006600;">oldValue</span>; <span style="color: #808080; font-style: italic;">// defined in some method</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">target</span>:<span style="color: #0066CC;">Object</span> = event.<span style="color: #006600;">targetObject</span>;
	<span style="color: #000000; font-weight: bold;">var</span> source:<span style="color: #0066CC;">Object</span> = event.<span style="color: #0066CC;">target</span>;
	<span style="color: #000000; font-weight: bold;">var</span> property:<span style="color: #0066CC;">String</span> = event.<span style="color: #006600;">property</span>; <span style="color: #808080; font-style: italic;">// defined in some method</span>
	<span style="color: #000000; font-weight: bold;">var</span> newValue:<span style="color: #66cc66;">*</span> = source<span style="color: #66cc66;">&#91;</span>property<span style="color: #66cc66;">&#93;</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>oldValue <span style="color: #66cc66;">!</span>= newValue<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">target</span><span style="color: #66cc66;">&#91;</span>property<span style="color: #66cc66;">&#93;</span> = newValue;
		event.<span style="color: #006600;">oldValue</span> = newValue; <span style="color: #808080; font-style: italic;">// reset oldValue, so the next time through its different</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>&#8230;I made all this from reading your posts, but I&#8217;m not sure how the garbage collection because everything&#8217;s referencing everything else.  It makes a lot more possible in event handling though!  Any ideas if this this is okay practice or how to make it better?</p>
<p>Thanks man!<br />
Lance</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: blog.betabong.com @ 2012-02-05 07:40:57 -->
