0

I have this variable in Model class:

[Bindable]
public var someXml:XML;

I've used BindingUtils to get notified when the XML changes:

BindingUtils.bindSetter(onChange, Model.getInstance(), "someXml");

private function onChange(value:Object):void {
    // do something
}

Function onChange gets triggered when I assign an XML to the variable, but not when I change some attribute of the XML:

Model.getInstance().someXml.@attr = "newValue";

Why?

2 Answers 2

2

Because XML isn't an EventDispatcher and so doesn't dispatch Change Events when it's contents change. It descends directly from Object, so there's no EventDispatcher.

Sign up to request clarification or add additional context in comments.

2 Comments

do you know a way to bind XML attributes?
I don't think there's a direct way of doing it. My suggestion would be to encapsulate the change you want to make to the xml in a method on the model, so you can dispatch the change event from the model and get the binding to fire that way. Model.getInstance().updateXML( attrName, newValue );
0

Check out the XMLNotifier class

"... Used for watching changes to XML and XMLList objects. Those objects are not EventDispatchers, so if multiple elements want to watch for changes they need to go through this mechanism. Call watchXML(), passing in the same notification function that you would pass to XML.notification. Use unwatchXML() to remove that notification."

Those are the only two functions of interest and I think they are self explanatory.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.