i’m trying to build what will essentially be a journal in as3. the date and text will be read from an XML file… a lot like a simple gallery where clicking on a thumbnail shows the larger picture but where the thumbnails is a date (pulled from the xml file) and the larger picture is the actual journal entry. so far i’ve been able to pull the xml file in and create new TextFields for each of the entrys in the xml file to hold the date but I’m to the point of pulling out my hair when it comes to associating the clicking of the date to showing the actual entry.
here is the xml file…
<?xml version="1.0" ?>
<entrys>
<entry date="October 26, 2008">Entry 4 - Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</entry>
<entry date="October 25, 2008">Entry 3 - Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</entry>
<entry date="October 24, 2008">Entry 2 - Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</entry>
<entry date="October 23, 2008">Entry 1 - Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</entry>
</entrys>
and here is the Actionscript…
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
var i:int = 0;
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("journey2.xml"));
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
ParseData(xmlData);
}
function ParseData(entryData:XML):void {
var entryContent:XMLList = new XMLList(entryData.entry);
for each (var entryElement:XML in entryContent) {
var dates:TextField = new TextField();
dates.width = 150;
dates.height = 20;
dates.x = 10;
dates.y = i*dates.height;
dates.selectable = false;
dates.text = entryElement.attributes();
dates.name = 'date'+i;
dates.addEventListener(MouseEvent.CLICK, changeContent);
trace(entryContent*);
trace(entryContent*.attributes());
addChild(dates);
addChild(contents);
i++;
}
// create a TextField to hold the journal entry
var contents:TextField = new TextField();
contents.width = 350;
contents.height = 400;
contents.x = 160
contents.y = 10;
contents.multiline = true;
contents.selectable = false;
contents.text = '';
function changeContent(e:MouseEvent):void {
// do something that causes the journal entry
// to change based on the date clicked.
}
}
i’m sure it’s something that should be easy but i’ve been pulling my hair out over this thing to 3 days now. yes, it’s probably very apparent that i’m an as3 novice. any help would be greatly appreciated.