See conference information here.
http://elearning.byol.com/
Traditionally, if you were to make a simulation that you didn't need to reuse, you would hard code it Flash using the timeline or MovieClips. The problem with creating a simulation this way is that if you want to reuse your code you will have to create the whole simulation over again, and to make changes to your simulation would require a lot of work. The problem I find with Quizzes is that there are a lot of tools out there that help you build quizzes but don't let you customize the look and feel to your liking.
So, basically this is trying to recreate what they have already created. There are pros and cons to creating a custom simulation or quiz but it is sure fun to do.
I first wanted to show how easy it is to use Excel 2007 to create XML documents.
Excel works great for populating a XML document because it feels like you are editing a spreadsheet or a database, you can copy and paste items and you don't have to create start and end tags for each time that you put in some text.
There are some downsides to using Excel as you can only create one level instead of having XML nodes nested inside of other XML nodes. They call this a recursive structure, which works great for creating a Menu, but Excel has trouble doing that kind of structure. There are ways around that though.
In this example, you will learn how to create an simple online book, using Flash, Excel and XML.
First we need to create our XML structure.
Open a code editor such as Dreamweaver and paste in the following code.
<?xml version="1.0" encoding="UTF-8"?>
<Book>
<Title></Title>
<Pages>
<Page>
<Text></Text>
</Page>
<Page>
<Text></Text>
</Page>
</Pages>
</Book>
For sake of simplicity we are just going to create a title for the book and pages using XML.To make sure that Excel knows that there will be more than one page we have to put at least two into our structure.
Save your XML Document.
Open Excel 2007.
Note: You can do this with Excel 2003 but the process is a little different.
To use the XML in Excel you need to have the Developer ribbon enabled.
To do this, click on the Microsoft Office Icon in the top left corner.
Select Excel Options
In the popular tab make sure that Show Developer tab in Ribbon is selected.
Click OK.
Next, click Open from the main menu.
Open the xml file that you saved previously.
When the Open XML pop-up appears select the third option "Use the XML Source task pane. "An XML Source box should open in the right side of the window.Drag the Title node to the B column.A little box should pop up next to it, click on the option to place the title to the left.This node is a non-repeating element. Next, drag the Page element to the D column. You will notice that this only shows the Text Node, this is because this is the only one that is editable in the Page. We could add other tags such as a page number or chapter number, but Text is enough for right now.
After you have finished mapping the cells. Fill in the spreadsheet. I chose the Count of Monte Cristo because it is in the public domain and can be found at the Gutenberg Project.http://www.gutenberg.orgSave the file.
Click inside a mapped cell.
Select the Developer ribbon and click Export.
Save the XML file to the same folder where you will create your Flash File.
After you have saved the .xml file go ahead and open it.
You should have something similar to what is found below.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Title>THE COUNT OF MONTE CRISTO</Title>
<Pages>
<Page>
<Text>On the 24th of February, 1815, the look-out at Notre-Dame de la Garde signalled the three-master, the Pharaon from Smyrna, Trieste, and Naples.</Text>
</Page>
<Page>
<Text>As usual, a pilot put off immediately, and rounding the Chateau d'If, got on board the vessel between Cape Morgion and Rion island.</Text>
</Page>
<Page>
<Text>Immediately, and according to custom, the ramparts of Fort Saint-Jean were covered with spectators; it is always an event at Marseilles for a ship to come into port, especially when this ship, like the Pharaon, has been built, rigged, and laden at the old Phocee docks, and belongs to an owner of the city.</Text>
</Page>
</Pages>
</Book>
Create a Flash File using Actionscript 3.0.It should have a dynamic text box for your page text, another dynamic text box for your page numbers and then a back and next button.Your final example could look something like this.First, we need to load in the XML.
var bookXML:XML;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
xmlLoader.load(new URLRequest("Count.xml"));
function xmlLoaded(e:Event):void {
bookXML = new XML(e.target.data);
trace(bookXML);
}
function xmlLoaded(e:Event):void {
bookXML = new XML(e.target.data);
trace(bookXML);
loadPage(0);
}
function loadPage(pNum:int):void {
page_txt.text = bookXML.Pages.Page[pNum].Text;
}
Next, we need to create a way to go forward and backward through each page.We will do this by creating a currentPage variable and a totalPages variable to help us know where we are in the book.
Place the following variables before the xmlLoaded functions.
var currentPage:int = 0;
var totalPages:int;
function xmlLoaded(e:Event):void {
bookXML = new XML(e.target.data);
totalPages = bookXML..Page.length();
trace(totalPages);
loadPage(currentPage);
next_btn.addEventListener(MouseEvent.CLICK, nextPage);
back_btn.addEventListener(MouseEvent.CLICK, backPage);
}
Next, we will modify the loadPage function.
function loadPage(pNum:int):void {
page_txt.text = bookXML.Pages.Page[pNum].Text;
currentPage = pNum;
pageNum_txt.text = (currentPage+1) + " / " + totalPages
}
Next, we will create our nextPage and backPage button functions.
function nextPage(e:MouseEvent):void {
if(currentPage <>
currentPage++
loadPage(currentPage);
}
}
function backPage(e:MouseEvent):void {
if(currentPage > 0){
currentPage--
loadPage(currentPage);
}
}
Here is the finished script.
var bookXML:XML;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
xmlLoader.load(new URLRequest("Count.xml"));
var currentPage:int = 0;
var totalPages:int;
function xmlLoaded(e:Event):void {
bookXML = new XML(e.target.data);
trace(bookXML);
totalPages = bookXML..Page.length();
trace(totalPages);
loadPage(currentPage);
next_btn.addEventListener(MouseEvent.CLICK, nextPage);
back_btn.addEventListener(MouseEvent.CLICK, backPage);
}
function loadPage(pNum:int):void {
page_txt.text = bookXML.Pages.Page[pNum].Text;
currentPage = pNum;
pageNum_txt.text = (currentPage+1) + " / " + totalPages
}
function nextPage(e:MouseEvent):void {
if(currentPage <>
currentPage++
loadPage(currentPage);
}
}
function backPage(e:MouseEvent):void {
if(currentPage > 0){
currentPage--
loadPage(currentPage);
}
}
No comments:
Post a Comment