Not trying to hijack
here but , how did you get a xml chain to bind? An yes a need for e4x features
would be most handy, but until i get just a
simple chain working can help ya ;)
I'm trying to do this
and getting no results at all? Dynamic
binding not working, from the docs it
say's… Works for a property
etc..
"call the method as: watch(host,
["a","b","c"], ...)
. "
When
binding to a chain. Go figure?
as
below
<mx:Script>
<![CDATA[
import
mx.binding.utils.*;
[Bindable]
public
var boundtarget:XML;
private function
Init_TargetBinding():void{
boundtarget = new
XML(<item><fullname>testing</fullname><toto>test2</toto></item>);
var
owatch:ChangeWatcher = BindingUtils.bindProperty(text1, "text",this ,
["boundtarget","item","fullname"]);
trace("Watched: " +
owatch.isWatching());
}
]]>
</mx:Script>
<mx:TextInput
click="Init_TargetBinding();" id="text1"/>
If
my array only containes boundtarget then i get the xml.
Jason
Hi. Yesterday, I set out on what
I thought would be a quick task using Flex – an E4X interpreter, where a
user can view an XML document as source and tree, type in E4X expressions,
and see the result of the _expression_. Ultimately, I wanted to be able to
perform assignments and see the effect (if any) on the XML. Nice little tool
to help learn E4X syntax.
As it turns out, this is a lot
more difficult than I thought. I was hoping there would be some way of
evaluating an E4X _expression_ held in a string. I have found that there was
an eval() function in previous versions of ActionScript, but it has been
dropped. I can understand that an open-ended eval() function might be a
security worry, but it seems a bit restrictive not being able to evaluate
E4X expressions held as a string. I have looked into these
approaches:
- Objects and Dynamic classes.
These allow you to assign functions to an object or class at runtime, but
only functions that are already defined within the source code. There’s no
way to create new function from string. Same reasoning as eval() I
guess.
- Event handlers for GUI
objects. I found it is not possible to assign to or access the “click”
property of a button, for example. Again, security reason I
guess.
- Bindings. I have tried various
ways of assigning the binding of a result field at runtime, the most
successful being the BindingUtils.bindProperty method. This works with
simple values and XML chains, but not with chains containing E4X features
such as searching, as in the following example:
BindingUtils.bindProperty(
txtField, "text", this, ["xdata","item","(@id=='3456')","description"]
);
I have had a look at the
generated ActionScript after compiling a project with a simple “curly
braces” bind to the E4X _expression_, and can see that functions have been
created to watch for changes to the XML object, and then recalculate the
_expression_, see if it has changed and if so update the text field (I
think…)
So anyway, short of rewriting
the entire E4X interpretation algorithms, or relying on a new component
being compiled dynamically at runtime, can anyone think of a way to do
this?
Cheers,
Tim