Hi,
I'm working on a background loading queue. It consists of a bunch of
iterators and iterator composites. To find the next thing to load, a
"has next" function recursively propagates down the tree, as it were,
until it reports back that there is another thing to load, or not.
The problem: When I debug, the queue works dandy, but the vanilla
Flash 9 player reports a stack overflow originating with "has next".
I have no idea what's going on, because I can't debug! But I do know
this strange fact: a trace statement in the "has next" function
corrects the problem, and queue is formed as it should be.
So if you've worked with recursion before: under what circumstances
would a slight delay in a recursive function prevent it from going
off the tracks?
Here's the relevant code:
public class SortIteratorComposite extends SortIterator implements
ISortIterableComposite
{
protected var curLeaf:ISortIterable;
public function SortIteratorComposite()
{
curLeaf=null;
}
public override function
hasNext(leaf:ISortIterable=null):Boolean
{
var more:Boolean=false;
//the superclass keeps track of the children
trace ("create a delay"+numChildren);
for (var i:uint=0; i<numChildren; i++)
{
//go down till a leaf iterator actually returns
a value
var child:ISortIterable=children[i];
//the recursion begins
if (child.hasNext(child))
{
leaf=child;
more=true;
break;
}
}
curLeaf=leaf;
return more;
}
public override function next():Object
{
//the leaf returns the next loadable
found=curLeaf.next();
return found;
}
Any help? I'm flummoxed.
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com