Hi,

The problem is not getting the assets - this works for both example functions.

The problem is that when I try to trace the childIndex() of the asset that has been found, it always returns -1 for the asset obtained by matching the child rather than the attribute.

    So the following e4x works, but the childIndex value does not.

var res:XMLList = _assets.(child("number") == String(prop));
if (0 != res.length()) {
    debug(this, "getAssetDetails " + res[0].childIndex());
    return res[0];
} else {
    return null;
}

    Here is a much shortened list of assets:

<entity>
<id>524</id>
<number>2001</number>
<name><![CDATA[Hello]]></name>
<description><![CDATA[Compose Audio]]></description>
<type>1</type>
<events_count>1</events_count>

<length>0.85</length>
<outputs>
</outputs>
</entity>
<entity>
<id>527</id>
<number>2004</number>

<name><![CDATA[Cry]]></name>
<description><![CDATA[Compose Audio]]></description>
<type>1</type>
<events_count>1</events_count>
<length>2.63</length>
<outputs>
</outputs>

</entity>
<entity>
<id>530</id>
<number>2007</number>
<name><![CDATA[Sob]]></name>
<description><![CDATA[Compose Audio]]></description>
<type>1</type>

<events_count>1</events_count>
<length>2.02</length>
<outputs>
</outputs>
</entity>

On 17/02/2011 12:30, Jens Struwe wrote:
May I refine your question?

"I have an XML tree. How can I select nodes depending on the value of subnodes or the value of subnode attributes".

Hi,

I am having a problem with getting the childIndex value from an e4x
result:

Both these functions work - e.g. they return an XML node from a list,
but the childIndex property always traces as -1 for the first function.

Can anyone see what the problem is?

TIA

Glen

public function getAssetDetails(prop:*):XML {
if (!_assets) {
return null;
}
var res:XMLList = _assets.(child("number") == String(prop));
if (0 != res.length()) {
debug(this, "getAssetDetails " + res[0].childIndex());
return res[0];
} else {
return null;
}
}

override public function getAssetDetails(prop:*):XML {
if (!_assets) {
return null;
}
var res:XMLList = _assets.(attribute("icon") == String(prop));
if (0 != res.length()) {
debug(this, "getAssetDetails " + res[0].childIndex());
return res[0];
} else {
return null;
}
}
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to