[Xerte] Problem getting accurate count of pages in framework

Julian Tenney Julian.Tenney at nottingham.ac.uk
Tue Oct 14 09:35:35 BST 2008


Try this:

 

http://www.nottingham.ac.uk/~cczjrt/pswanson.rlo

 

 

 

From: xerte-bounces at lists.nottingham.ac.uk
[mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Paul Swanson
Sent: Monday, October 13, 2008 10:08 PM
To: Xerte discussion list
Subject: RE: [Xerte] Problem getting accurate count of pages in
framework

 

Here is what I have:

 

A page off the Interface page with an id of 'aboutDP' which contains a
framework with an id of aboutDPFrame. The aboutDPFrame has an Entry
Frame, with an onInit event interaction (eventName = onInit, icon =
rootIcon, erase = 0, exit = 1). To this event is attached a script icon
with 'aboutDPpageCount = aboutDPFrame.pages.length;'. The entry frame
also includes a script icon with an id of 'aboutDPCounter' positioned
where I want the page numbers to appear.

 

The framework has a number of pages, each with a script icon (I'll
change to the onPageOpen event once I've got the page count working)
with: aboutDPCounter.setText('Page ' + (aboutDPFrame.currentPage + 1) +
' of ' + aboutDPCount);

 

What prints is 'Page 1 of undefined', 'Page 2 of undefined', etc. So I
still must not have the event set up correctly...

 

P

	 

	
________________________________


	From: xerte-bounces at lists.nottingham.ac.uk
[mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Julian Tenney
	Sent: Monday, October 13, 2008 1:08 PM
	To: Xerte discussion list
	Subject: RE: [Xerte] Problem getting accurate count of pages in
framework

	rootIcon fires onInit; all frameworks fire onPageOpen,

	 

	HTH,

	 

	J

	 

________________________________

	From: xerte-bounces at lists.nottingham.ac.uk on behalf of Paul
Swanson
	Sent: Mon 13/10/2008 18:08
	To: Xerte discussion list
	Subject: RE: [Xerte] Problem getting accurate count of pages in
framework

	I still have not got this to work. What icon id should be used
for the icon property of the Event Interaction? I've tried the icon id
of the framework, the icon id of the page holding the framework,
rootIcon, and the icon id of the first child page of the framework -- in
the first three cases I get 'undefined' as the value of
aboutDPFrame.pages.length, and in the last case I get 0 (which doesn't
surprise me). And should the onPageOpen be within the onInit event, or
should that be a separate event?

	 

	Paul

		 

		
________________________________


		From: xerte-bounces at lists.nottingham.ac.uk
[mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Julian Tenney
		Sent: Wednesday, October 08, 2008 2:43 PM
		To: Xerte discussion list
		Subject: RE: [Xerte] Problem getting accurate count of
pages in framework

		An .rlo is an xml tree. It is parsed sideways like an AW
dive. Content is created as each node is encountered:

		 

		//this is really what the engine does...

		function parse(node){ //a node from the .rlo file's xml

		 

		  //do things with the node - like create an icon or
execute some script

		  //instantiate classes using the information from the
xml node to create icons

		  //icons will intialise before this code continues

		  //script icons are executed here too, in engine scope

		  

		  //then loop over each child of node, calling this
function recursively

		  for (var i = 0; i < node.childNodes.length; i++){

		    parse(node.childNodes[i]);

		  }

		 

		  //decide whether to break or continue?

		}

		 

		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.

		 

		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. 

		 

		Only then are the rest of the pages are created - but -
by definition - you cannot place code in page 1 that will execute
afterwards.

		 

		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.

		 

		J

		 

________________________________

		From: xerte-bounces at lists.nottingham.ac.uk on behalf of
Paul Swanson
		Sent: Wed 08/10/2008 17:53
		To: xerte at lists.nottingham.ac.uk
		Subject: [Xerte] Problem getting accurate count of pages
in framework

		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).

		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:

		aboutDPCounter.setText('Page ' +
(aboutDPFrame.currentPage + 1) + ' of ' + aboutDPFrame.pages.length; 

		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."

		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.

		_____________________________ 

		 Paul Swanson 
		 Instructional Designer 
		 Harland Financial Solutions 
		 800.274.7280 Ext. 2462 
		 Paul.Swanson at harlandfs.com 
		_____________________________ 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.nottingham.ac.uk/pipermail/xerte/attachments/20081014/65ff3b16/attachment.html


More information about the Xerte mailing list