Your easiest option will be to wrap your XML in a XMLlistCollection which
will throw events you can listen to. If that won't work you can check out
mx.utils.XMLNotifier, mx.utils.IXMLNotifiable, and mx.binding.XMLWatcher but
keep in mind that these classes were hidden for a reason. I'm sure they are
subject to change and they are not documented so only use them if you need
to.
- Dan
On 1/26/07, hosey hosey <[EMAIL PROTECTED]> wrote:
I would like to call a function when an xml attribute changes. None of
the isWatching() calls return true.......Is there a way to watch/bind
frelling notice when an attribute of an XML gets changed?????
package {
import flash.display.Sprite;
public class test extends Sprite{
import mx.binding.utils.BindingUtils;
import mx.binding.utils.ChangeWatcher;
[Bindable]
public var xml:XML=<a>
<b id="1">
<b id="2"/>
<b id="3"/>
</b>
</a>;
public var out:String=""
public function test() {
var watcher:ChangeWatcher = ChangeWatcher.watch (this,
["xml.b[0].b.(@id=='3')[EMAIL PROTECTED]"]
, this.changed);
trace(watcher.isWatching ())
var watcherSetter:ChangeWatcher= BindingUtils.bindSetter(
function(v:String):void {trace("WE"+v)},
xml.b [0].b.(@id=='3')[0], "@id")
var watcherSetter2:ChangeWatcher= BindingUtils.bindSetter(
function(v:String):void {trace("WEE"+v)},
xml..b.(@id=="3")[0], "@id")
trace(watcherSetter.isWatching())
trace(watcherSetter2.isWatching())
xml.b[0].b.(@id=='3')[EMAIL PROTECTED]"5"
trace(xml.b [0])
}
private function changed():void{
trace("wee")
}
}
}
Thanks
Hosey