Results 1 to 7 of 7

Thread: XML Events page (help needed)

  1. #1
    Join Date
    Dec 2007
    Location
    Mississauga
    Posts
    166
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Question XML Events page (help needed)

    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
    HTML Code:
    <broadcast>
    <story>
    <lead>Event01</lead>
    </story>
    <story>
    <lead>Event02</lead>
    </story>
    <story>
    <lead>Event03</lead>
    </story>
    </broadcast>
    XML for events content
    HTML Code:
    <?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
    HTML Code:
    // 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
    HTML Code:
    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
    HTML Code:
    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

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Have a look at this thread from a few days ago. In it I helped someone create a dynamic XML powered "slideshow". The same principals apply here.

    See if that jogs your ideas a little. If not, post back and I'll be less vague :-p. I'm in a lazy mood at the moment or I'd post some code.

  3. #3
    Join Date
    Dec 2007
    Location
    Mississauga
    Posts
    166
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Default

    Hey Medyman,

    Thanks again for trying to help out, I can understand feeling lazy it's the weekend and the fact that your offering help is really cool of you.

    I looked over the post you sent me and I could be wrong since I am not sure what I am looking for but it doesnt seem to help me for my current situation, but like I said I could be wrong.

    I don't want to make you go through the trouble of posting code and the events page doesnt even have to have animations in and out per event.

    I am just looking to have a basic page, all the XML on one XML page vs the two I have now so that way the person can use a CMS to add events and as described before each event would have a flyer/image and a blurb about the event.

    Any tips/suggestions/tutorials?

  4. #4
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Hey Nate,

    I'm not quite sure what your setup is like. It seems a bit more complicated than it needs to be. What's the purpose of the two XML documents? Are you using a different XML file for EACH event?

    In fact, the other post I linked to is exactly what you're asking here. The user there had a 40-page application (40 XML nodes) and he was using 1 frame per node. I showed him how to dynamically call the data and so 40+ frames are now 1.

    You can read my descriptions there regarding the specific techniques. Pay specific attention to the loadImages(), goForward(), and goBackward() functions.

    It's much easier for me to post code than to explain in vague, abstract terms. So, here is an example that is more explicitly apropos to what you're trying to do.

  5. #5
    Join Date
    Dec 2007
    Location
    Mississauga
    Posts
    166
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Default

    Medyman,

    Yes the example you sent over makes more sense to me now that I can see it.

    The issue of using the two XML pages is I am having trouble figuring out how to have flash call up a specific variable in list of events but only the content on the first line in the XML, then when you select the second option only the contents of the second line, etc.

    Your example is on the basis of what I am looking for with the image and text changing on selection, but instead of the forward and back buttons I need to make a list of events, for the example you gave it would be...
    CHUCK
    HEROS
    LIPSTICK JUNGLE

    And when someone selects one of those options that's when you get the image and caption for it.

    That's where my major problem is, but having the contents (image and caption) on one XML file isnt an issue (so far).

    Learning XML and AS for it is like learning a new language and lets just say I failed french many times.

  6. #6
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Ok, I see what you're doing now. That's also all doable with one XML file.

    Here is something I just put together real quick. You don't need to call the XML all at once. You can call whatever you need, whenever you need it. So, if you only want to parse the titles at first, do so. Then, call the images. The important thing to remember is how to call the values in XML.

    If you have any questions, post back.

  7. The Following User Says Thank You to Medyman For This Useful Post:

    nate51 (10-22-2008)

  8. #7
    Join Date
    Dec 2007
    Location
    Mississauga
    Posts
    166
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Default

    Medyman you did it again!

    That is it to a "T" the only thing I need to look into is how to designate the list to a space on the stage that I chose but that is something I should learn myself, and you're right the code is pretty short and simple.

    This is going to be a handy script to learn from as it's really clean and clear.

    I cannot thank you enough, I hope others can benifit from this post.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •