nate51
10-19-2008, 05:20 AM
I am working on a site that has an events and gallery page that work the same way.
3 boxes, one loads a list to select from, the second box loads in a blurb and the third box loads in an image from the event.
I have a slightly working version that loads in the events list (date and location) the first event loads properly with the blurb and image. The way I have this working is the second frame loads in the next event image and blurb, third frame does third etc. I know there are better ways of doing this but many searches over the net and forums has left me lost on how to do this.
Below is my codes.
XML for events date
<broadcast>
<story>
<lead>Event01</lead>
</story>
<story>
<lead>Event02</lead>
</story>
<story>
<lead>Event03</lead>
</story>
</broadcast>
XML for events content
<?xml version="1.0" encoding="utf-8"?>
<events>
<photo url01="images/events/flyer01.jpg" captions01="event blurb1" />
<photo url02="images/events/flyer02.jpg" captions02="event blurb2" />
<photo url03="images/events/flyer03.jpg" captions03="event blurb3" />
</events>
The first frame loads in the events list which works fine but here it is anyways
// The first step is to activate the XML object
headlineXML = new XML();
/*
With the XML Object now active you must now load an XML foramtted document.
Any DTD or XLS formatting will be ignored.
*/
headlineXML.onLoad = myLoad;
headlineXML.load("event-date.xml");
// Before proceeding to far into the program, make sure the XML document has loaded
// Extract information from the XML file
function myLoad(ok) {
if (ok == true) {
Publish(this.firstChild);
}
}
function Publish(HeadlineXMLNode) {
if (HeadlineXMLNode.nodeName.toUpperCase() == "BROADCAST") {
content = "";
story = HeadlineXMLNode.firstChild;
while (story != null) {
if (story.nodeName.toUpperCase() == "STORY") {
lead = "";
element = story.firstChild;
while (element != null) {
if (element.nodeName.toUpperCase() == "LEAD") {
lead = element.firstChild.nodeValue;
}
element = element.nextSibling;
}
content += "<font size='+1' color='#FFFFFF'>"+lead+"</font><br>";
txt.htmlText=content;
}
story = story.nextSibling;
}
}
}
But here is the AS for the 2nd frame which loads in the content
var x:XML = new XML();
x.ignoreWhite = true;
var captions:Array = new Array();
var urls:Array = new Array();
x.onLoad = function() {
var photos:Array = this.firstChild.childNodes;
for(i=0;i<photos.length;i++) {
captions.push(photos[i].attributes.captions01);
urls.push(photos[i].attributes.url01);
}
holder.loadMovie(urls[0]);
caption.text = captions[0];
}
x.load("events.xml");
stop();
The problem is when you click to go to the next event the event list is still there but the content doesnt work, below is the AS
var x:XML = new XML();
x.ignoreWhite = true;
var captions:Array = new Array();
var urls:Array = new Array();
x.onLoad = function() {
var photos:Array = this.firstChild.childNodes;
for(i=0;i<photos.length;i++) {
captions.push(photos[i].attributes.captions02);
urls.push(photos[i].attributes.url02);
}
holder.loadMovie(urls[0]);
caption.text = captions[0];
}
x.load("events.xml");
stop();
Obviously small changes were made to variables to bring in a new image and new blurb.
Can anyone help point me in the right direction or give some tips/tutorials to how to do this?
I am drawing blanks.
-- Nate
3 boxes, one loads a list to select from, the second box loads in a blurb and the third box loads in an image from the event.
I have a slightly working version that loads in the events list (date and location) the first event loads properly with the blurb and image. The way I have this working is the second frame loads in the next event image and blurb, third frame does third etc. I know there are better ways of doing this but many searches over the net and forums has left me lost on how to do this.
Below is my codes.
XML for events date
<broadcast>
<story>
<lead>Event01</lead>
</story>
<story>
<lead>Event02</lead>
</story>
<story>
<lead>Event03</lead>
</story>
</broadcast>
XML for events content
<?xml version="1.0" encoding="utf-8"?>
<events>
<photo url01="images/events/flyer01.jpg" captions01="event blurb1" />
<photo url02="images/events/flyer02.jpg" captions02="event blurb2" />
<photo url03="images/events/flyer03.jpg" captions03="event blurb3" />
</events>
The first frame loads in the events list which works fine but here it is anyways
// The first step is to activate the XML object
headlineXML = new XML();
/*
With the XML Object now active you must now load an XML foramtted document.
Any DTD or XLS formatting will be ignored.
*/
headlineXML.onLoad = myLoad;
headlineXML.load("event-date.xml");
// Before proceeding to far into the program, make sure the XML document has loaded
// Extract information from the XML file
function myLoad(ok) {
if (ok == true) {
Publish(this.firstChild);
}
}
function Publish(HeadlineXMLNode) {
if (HeadlineXMLNode.nodeName.toUpperCase() == "BROADCAST") {
content = "";
story = HeadlineXMLNode.firstChild;
while (story != null) {
if (story.nodeName.toUpperCase() == "STORY") {
lead = "";
element = story.firstChild;
while (element != null) {
if (element.nodeName.toUpperCase() == "LEAD") {
lead = element.firstChild.nodeValue;
}
element = element.nextSibling;
}
content += "<font size='+1' color='#FFFFFF'>"+lead+"</font><br>";
txt.htmlText=content;
}
story = story.nextSibling;
}
}
}
But here is the AS for the 2nd frame which loads in the content
var x:XML = new XML();
x.ignoreWhite = true;
var captions:Array = new Array();
var urls:Array = new Array();
x.onLoad = function() {
var photos:Array = this.firstChild.childNodes;
for(i=0;i<photos.length;i++) {
captions.push(photos[i].attributes.captions01);
urls.push(photos[i].attributes.url01);
}
holder.loadMovie(urls[0]);
caption.text = captions[0];
}
x.load("events.xml");
stop();
The problem is when you click to go to the next event the event list is still there but the content doesnt work, below is the AS
var x:XML = new XML();
x.ignoreWhite = true;
var captions:Array = new Array();
var urls:Array = new Array();
x.onLoad = function() {
var photos:Array = this.firstChild.childNodes;
for(i=0;i<photos.length;i++) {
captions.push(photos[i].attributes.captions02);
urls.push(photos[i].attributes.url02);
}
holder.loadMovie(urls[0]);
caption.text = captions[0];
}
x.load("events.xml");
stop();
Obviously small changes were made to variables to bring in a new image and new blurb.
Can anyone help point me in the right direction or give some tips/tutorials to how to do this?
I am drawing blanks.
-- Nate