you dont 'delay' the return function, just consider that each invocation of the function can pass back a result to the calling function

the idea is something like this (its not tested code, but hopefully will give you a starting point...)

also, it assumes that each node has only one child, otherwise you would need to find multiple paths

function findTransitionPath(node:XMLNode, attributeName:String):Array
{
        if(node.childNodes.length == 1)
        {
                // check children for transition attributes in nodes
                var path:Array = findTransitionPath(node.childNodes[0], 
attributeName);
        }
        else
        {
                // no children, so sub path is empty
                path = [];
        }

        // check this node
        if(node.attributes.transition != null)
        {
                // make this node the start of the array
                return [node.attributes.transition].concat(path);
        }
        else
        {
                // just return the array from our children
                return path;
        }
}

there may be better ways to do this... :)

thanks,

Martin

Robin Burrer wrote:
Hi everybody,

I try to build a recursive function that searches an xml node for a
particular attribute name.
Each Node of my xml document has an attribute called "transition".

So basically what I want to do is pass an xml node to my function and the name of the transition and in return I want to get the path to the
transition (which should be an array).

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

Reply via email to