<HTML dir=ltr><HEAD><TITLE>Problem getting accurate count of pages in framework</TITLE>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.6000.16705" name=GENERATOR></HEAD>
<BODY>
<DIV id=idOWAReplyText86825 dir=ltr>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2>An .rlo is an xml tree. It is parsed sideways like an AW dive. Content is created as each node is encountered:</FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>//this is really what the engine does...</FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2>function parse(node){ //a node from the .rlo file's xml</FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2> //do things with the node - like create an icon or execute some script</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2> //instantiate classes using the information from the xml node to create icons</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2> //icons will intialise before this code continues</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2> //script icons are executed here too, in engine scope</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2> </FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2> //then loop over each child of node, calling this function recursively</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2> for (var i = 0; i < node.childNodes.length; i++){</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2> parse(node.childNodes[i]);</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2> }</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2> //decide whether to break or continue?</FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2>}</FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2>As the tree is parsed, the entry frame and it's content is created. At this point the rest of the framework's xml hasn't been parsed.</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>Flow moves to the next child node of the framework's xml - the first page. The page is created and it's content's parsed. The second page hasn't been parsed yet, so 1 of 1 is expected. </FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>Only then are the rest of the pages are created - but - by definition - you cannot place code in page 1 that will execute afterwards.</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>for that very reason there is the onInit event. This event is broadcast by rootIcon when the initial parse IS complete. Use this in the entry frame to initialise your interface, and use onPageClose / onPageOpen rather than have code in each page to set the interface items. onInit will correct give you fw.pages.lenth, and onPageClose / onPageOpen are more elegant / easier to maintain than code on each page.</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>J</FONT></DIV></DIV>
<DIV dir=ltr><BR>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> xerte-bounces@lists.nottingham.ac.uk on behalf of Paul Swanson<BR><B>Sent:</B> Wed 08/10/2008 17:53<BR><B>To:</B> xerte@lists.nottingham.ac.uk<BR><B>Subject:</B> [Xerte] Problem getting accurate count of pages in framework<BR></FONT><BR></DIV>
<DIV>
<P><FONT face=Verdana size=2>I'm adding a "Page x of y" to a framework, and I'm not getting the correct value for y (the number of pages in the framework).</FONT></P>
<P><FONT face=Verdana size=2>I'm using an Entry Frame to the framework, and within that is a text icon with an id of aboutDPCounter. The framework id is aboutDPFrame. On each page, I include a script icon with the following:</FONT></P>
<P><FONT face=Verdana size=2>aboutDPCounter.setText('Page ' + (aboutDPFrame.currentPage + 1) + ' of ' + aboutDPFrame.pages.length;</FONT> </P>
<P><FONT face=Verdana size=2>When I enter the framework, which currently has two pages of content, the page counter reads "Page 1 of 1." When I go to the next page, it reads "Page 2 of 2," and when I back to the first page it reads "Page 1 of 2." If I then advance to page 2, it reads "Page 2 of 2."</FONT></P>
<P><FONT face=Verdana size=2>What's going on? I would expect myFramework.pages.length would be consistent. It appears as though it doesn't count the page until you've actually navigated to it.</FONT></P>
<P><FONT face="Courier New" color=#808080 size=2>_____________________________</FONT> </P>
<P><FONT face="Courier New" color=#808080 size=2> Paul Swanson</FONT> <BR><FONT face="Courier New" color=#808080 size=2> Instructional Designer</FONT> <BR><FONT face="Courier New" color=#808080 size=2> Harland Financial Solutions</FONT> <BR><FONT face="Courier New" color=#808080 size=2> 800.274.7280 Ext. 2462</FONT> <BR><FONT face="Courier New" color=#808080 size=2> Paul.Swanson@harlandfs.com</FONT> <BR><FONT face="Courier New" color=#808080 size=2>_____________________________</FONT> </P></DIV></BODY></HTML>