A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [RESOLVED] [F8] Calendar Problem

  1. #1
    Member
    Join Date
    Nov 2003
    Location
    Ontario, Canada
    Posts
    80

    resolved [RESOLVED] [F8] Calendar Problem

    I have successfully written code to save XML info to a variable.

    However, in my program wen I check teh data to see if there is an event on that particular day, it checks before the XML is loaded.

    How is this possible when the function to load teh XML is well before the one to use the data??
    Attached Files Attached Files

  2. #2
    Member
    Join Date
    Nov 2003
    Location
    Ontario, Canada
    Posts
    80
    Gen, we shoudl get EVP to turn on the TS, its been too long since ive listened to all the witty banter.

  3. #3
    Senior Member
    Join Date
    Jan 2006
    Posts
    263
    You should put your load function after the onload function.

    myxml.onload// Put first

    myxml.load//Put after your on load function and it should work just fine

  4. #4
    Member
    Join Date
    Nov 2003
    Location
    Ontario, Canada
    Posts
    80
    I have a function populateEventDates();

    inside this function it calls a function loadEventXML();

    this is my XML function:

    Code:
    loadEventXML = function(month:Number){
    	var events_xml = new XML(); 
    	events_xml.ignoreWhite = true; 
    	events_xml.onLoad = function(success){ 
    		
    		if (success) {
    			for (var i:Number = 1; i <= events_xml.childNodes.length; i++){
    				var eventDate = events_xml.childNodes[i-1].childNodes[0].firstChild.nodeValue;
    				var eventName = events_xml.childNodes[i-1].childNodes[1].firstChild.nodeValue;
    				var eventText = events_xml.childNodes[i-1].childNodes[2].firstChild.nodeValue;
    				_root.eventData[i*3-3] = eventDate;
    				_root.eventData[i*3-2] = eventName;
    				_root.eventData[i*3-1] = eventText;
    			}
    			trace("XML Data for " + monthNames[month] + " loaded");
    		}else{
    			trace("Error loading XML file for " + monthNames[month]); 
    		}
    	} 
    events_xml.load("xml/" + (month+1)+".xml");
    }
    Later in teh populateDates() fucntion it calls a fuunction that uses the XML data now saved to eventData.

    Code:
    checkForEvent = function(dateCheck:Number){
    	trace("Checking For Event");
    	for (var index:Number = 0; index<=_root.eventData.length; index++){
    		trace("Looking for event");
    		if (_root.eventData[index] == dateCheck){
    			trace("Return Event " + _root.eventData[i+1]);
    			return _root.eventData[i+1];
    		}
    	}
    	trace("No Event Found");
    	return "";
    }
    Even though checkForEvent is loaded after loadEventXML, ,in teh trace window I still get "Looking for event" traced once for every check and at teh end I get "Data for " + monthNames[month] + " loaded". Why is the XML not loaded by now?

  5. #5
    Member
    Join Date
    Nov 2003
    Location
    Ontario, Canada
    Posts
    80
    Finally figured it out.

    Put the coad that requirest teh XML data inside the onLoad function. I dont know why it was calling it in the wrong order to begin wiht, but this fixed it and it all works YEAH!! www.zetapsioshawa.org hit the events button. WOOT!

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center