I'm in the process of switching some of my apps over to AS3, with one class
used to access and XML object giving me a fits.

The class is used to navigate through a serious of pages, with the XML
acting like the table of contents (chapter/topic/page). Applications using
this class would make calls like myClass.nextPage() and be given the
location of the swf to load, as well as other metadata about that page.

Simple enough in AS2. When the XML loads, I grab a reference to the first
page in the book and store it in a class variable (psudo code):

          _currentPage = _toc.firstChild.firstChild.firstChild ;

and then subsequent calls to nextPage would use:

          _currentPage =_currentPage.nextSibling ;
           return _currentPage ;


The code itself seems simple to port to AS3, however, I'm not getting the
results I'm expecting:

           _currentPage = _toc.chapter[0].topic[0].page[0] ;

works fine however

           _currentPage =_currentPage.parent().children()[node.childIndex()
+ 1];
           return _currentPage ;


causes an error. The failure appears to be _currentPage.parent() as this is
returning null.

So after that long winded description, my fear/guess at this point is that
the XML object _currentPage when set by  _toc.chapter[0].topic[0].page[0]
is creating an *isolated XML fragment* with no connection to the parent XML
object. This differs from how I was working in AS2, where the XMLNode
"_currentPage" behaved like a pointer to the position of the node within the
XML object.

Is this assumption correct?  If so, know any way of getting around it?
Would using _currentPage as an XMLNode solve the problem, and if so, is it
possible to perform E4X filters/searches on an XMLNode or is it back to
XPath for AS3?

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

Reply via email to