JSFiddle - React, Tailwind, and code Playground
HTML
<figure class="code">
<figcaption><strong>Listing 5</strong> ActionScript binding using ChangeWatcher</figcaption>
<pre class="prettyprint linenums">
<code><?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
applicationComplete="init()">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<fx:Script>
<![CDATA[
import mx.events.PropertyChangeEvent; <mark data-cueId="5-A">A</mark>
import mx.binding.utils.ChangeWatcher; <mark data-cueId="5-A">A</mark>
protected var _watcher:ChangeWatcher;
protected function init():void{
toggleWatch();
}
protected function toggleWatch():void{
if(_watcher && _watcher.isWatching()){ <mark data-cueId="5-C">C</mark>
_watcher.unwatch(); <mark data-cueId="5-D">D</mark>
toggleButton.label = "Watch"; <mark data-cueId="5-E">E</mark>
}else{
_watcher = ChangeWatcher.watch(inputField,"text",onTextChange); <mark data-cueId="5-B">B</mark>
toggleButton.label = "Stop Watching";
}
}
protected function onTextChange(event:Event):void{
myLabel.text = inputField.text;
}
]]>
</fx:Script>
<s:Button id="toggleButton" label="Watch Text" click="toggleWatch()"/>
<s:TextInput id="inputField" text="start text"/>
<s:Label id="myLabel" />
</s:Application></code>
</pre>
<ul class="annotations">
<li data-aId="5-A">Necessary imports to dynamically bind variables</li>
<li data-aId="5-B">Tells ChangeWatcher to detect changes</li>
<li data-aId="5-C">Checks list of watched variables</li>
<li data-aId="5-D">Removes watched variable</li>
<li data-aId="5-E">Yeah, I'm just making this up.</li>
</ul>
</figure>