<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>mandarin.no &#187; property</title>
	<atom:link href="http://mandarin.no/tag/property/feed/" rel="self" type="application/rss+xml" />
	<link>http://mandarin.no</link>
	<description></description>
	<lastBuildDate>Tue, 17 Aug 2010 09:35:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>AS3 Snippet #2: Watch for changing properties</title>
		<link>http://mandarin.no/as3/as3-snippet-2-watch-for-changing-properties/</link>
		<comments>http://mandarin.no/as3/as3-snippet-2-watch-for-changing-properties/#comments</comments>
		<pubDate>Mon, 07 Apr 2008 14:32:13 +0000</pubDate>
		<dc:creator>Thomas Viktil</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[changewatcher]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[property]]></category>
		<guid isPermaLink="false">http://d2997367.u306.hosted.servetheworld.net/?p=4</guid>
		<description><![CDATA[Today I stumbled across a handy utility class called ChangeWatcher, which lives inside the mx.binding.utils package. It provides you with a handy way of watching other object&#8217;s properties. Here&#8217;s how it&#8217;s used: ChangeWatcher.watch(object, &#8220;property&#8221;, handler); Object &#8211; the object which owns the property &#8220;property&#8221; &#8211; the property you want to watch handler &#8211; the function [...]]]></description>
			<content:encoded><![CDATA[<p>Today I stumbled across a handy utility class called ChangeWatcher, which lives inside the mx.binding.utils package. It provides you with a handy way of watching other object&#8217;s properties.</p>
<p>Here&#8217;s how it&#8217;s used:</p>
<blockquote><p>
ChangeWatcher.watch(object, &#8220;property&#8221;, handler);
</p></blockquote>
<p>Object &#8211; the object which owns the property<br />
&#8220;property&#8221; &#8211; the property you want to watch<br />
handler &#8211; the function name of the handler</p>
<p>Whenever the property of the object changes, the handler will respond. Quite handy, right?</p>
<p><em>edit:</em></p>
<p>Here&#8217;s an example for you:</p>
<p>Let&#8217;s say we have a class called WatchMe. Inside that class we have a public variable called ImBeingWatched. We&#8217;d like to trigger a function whenever this variable changes. To do this, we simply add one line of code:</p>
<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">binding</span>.<span style="color: #006600;">utils</span>.<span style="color: #66cc66;">*</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #66cc66;">*</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #66cc66;">*</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> WatchMe <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span> <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> ImBeingWatched:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">true</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> WatchMe<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			ChangeWatcher.<span style="color: #0066CC;">watch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>, <span style="color: #ff0000;">&quot;ImBeingWatched&quot;</span>, doSomething<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> doSomething<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">// do something ...</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>
<p>As you can see, this works pretty much like using [Bindable] variables. But, in some cases this method proves quite handy.</p>
<p>Update: Oops! Typo. The property that ChangeWatcher is watching must be [Bindable] and Public for it to work.</p>
]]></content:encoded>
			<wfw:commentRss>http://mandarin.no/as3/as3-snippet-2-watch-for-changing-properties/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
