dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Huge XML example code chunk for yall

  1. #1
    Junior Member
    Join Date
    Mar 2001
    Posts
    20
    Crew -

    We are writing a major Flash version of our application for
    individualnetwork.com.I thought that since this community
    has been a big help, I would post some of this code
    below. I have taken out some of the specific XML calls
    for the sake of security.

    There are MANY different things going on here, as you will
    be able to easily tell.

    If you are like me, and you like to copy and paste other
    people's code, this one will be a bear for you! This is
    not the best example of a "simple tutorial" on XML.

    First, we make 6 or 7 SIMULTANEOUS XML HTTP requests (in
    the Loads in Initialize). Then, we have 6 or 7 different
    handlers (signified in the different XML.onLoads defined in the
    intialize() function). You never know when the XML data will be returned, so many of these execute at the same
    time. Once all the different XMLs have been interpreted,
    we continue on with the application. Here is the basic
    sequence of the screen:


    1) Load the metadata
    2) Load the users for the account and display them on the screen
    3) The user clicks on a login then clicks the Start button
    (which does the initial OtherXML.load());
    4) We load all of the data that is specific to a
    particular user.

    Also please note that this is a preliminary version of
    this. It works fine, but we have yet to find the time to
    optimize it!


    First, here is an example of one of the 10 to 14 XML files we are calling
    (remember, too, that the structure of the XML parsing code is dependant upon the number of levels inside the XML doc). Just paste the following code into
    your browser window to see.


    http://p.moreover.com/cgi-local/page...ews&o=xml&n=35


    and here is the monster code:

    [CODE]
    //
    // turns on debugging windows for whole app (see myTrace())
    //
    debug = false;
    //
    // set the current screen and back screen for PREVIOUS purposes
    //
    PreviousScreen = CurrentScreen;
    CurrentScreen = "Login Screen";
    //
    // set the text of the title
    //
    currentScreenTitle = "LOGIN";
    //
    // call initializeApp to begin the process of loading the metadata and preparing all variables
    //
    initializeApplication();
    //
    // ================================================== ================================================== =============
    // FUNCTION goAhead -- Plays the Snapshot page after the user data has been loaded
    // ================================================== ================================================== =============
    //
    function goAhead () {
    gotoAndPlay ("Snapshot", 1);
    }
    //
    // ================================================== ================================================== =============
    // FUNCTION metaDataTest - test for complete loading of metadata
    // ================================================== ================================================== =============
    //
    function metaDataTest () {
    if ((ethLoaded) && (marLoaded) && (eduLoaded) && (lanLoaded) && (incLoaded) && (occLoaded)) {
    accountLoginsXML.load("http://www.lemonjello.com/whatever.jsp (returning an XMLfile)");
    }
    }
    //
    // ================================================== ================================================== =============
    // FUNCTION convertEthnicityXML - grabs all of the ethnicity metadata
    // ================================================== ================================================== =============
    //
    function convertEthnicityXML () {
    if (this.loaded) {
    metaData.canChange = "ETHNICITY";
    myTrace("ethnicityXML data loaded. Text parsing beginning.");
    }
    // keep track of following boolean so we know the first number in this array
    firstOneInSequenceFound = false;
    mainTagXML = new XML();
    mainTagXML = this.firstChild.nextSibling;
    if (mainTagXML.nodeName.toLowerCase() == "ethnicity") {
    ethnicityCode = new Array();
    levelTwoXML = new XML();
    levelTwoArray = new Array();
    myTrace("First Node ethnicity found");
    levelTwoArray = mainTagXML.childNodes;
    for (j=0; j<levelTwoArray.length; j++) {
    if (levelTwoArray[j].nodeName.toLowerCase() == "row") {
    myTrace("Node row found and the loopcounter is "+j);
    levelThreeXML = new XML();
    levelThreeArray = new Array();
    levelThreeArray = levelTwoArray[j].childNodes;
    for (w=0; w<levelThreeArray.length; w++) {
    if (levelThreeArray[w].nodeName.toLowerCase() == "name") {
    myTrace("Node name found");
    levelThreeXML = levelThreeArray[w];
    name = trimWithoutTruncate(levelThreeXML.firstChild.nodeV alue);
    myTrace(name);
    }
    if (levelThreeArray[w].nodeName.toLowerCase() == "id") {
    myTrace("Node id found");
    levelThreeXML = levelThreeArray[w];
    id = trimWithoutTruncate(levelThreeXML.firstChild.nodeV alue);
    myTrace(id);
    if (!firstOneInSequenceFound) {
    // mark the bottom most element of the array
    ethnicityBottomMost = id;
    firstOneInSequenceFound = true;
    }
    ethnicityCode[id] = name;
    myTrace("ethnicityCode["+id+"] = "+name);
    }
    }
    }
    }
    // top most gets the most recent ID
    ethnicityTopMost = id;
    ethLoaded = true;
    // see if it is time to get rid of the LOADING METADATA popup
    metaDataTest();
    }
    }
    //
    // ================================================== ================================================== =============
    // FUNCTION convertMaritalXML - grabs all of the marital metadata
    // ================================================== ================================================== =============
    //
    function convertMaritalXML () {
    if (this.loaded) {
    metaData.canChange = "MARITAL";
    myTrace("maritalXML data loaded. Text parsing beginning.");
    }
    mainTagXML = new XML();
    mainTagXML = this.firstChild.nextSibling;
    if (mainTagXML.nodeName.toLowerCase() == "marital_status") {
    maritalStatusCode = new Array();
    levelTwoXML = new XML();
    levelTwoArray = new Array();
    myTrace("First Node marital_status found");
    levelTwoArray = mainTagXML.childNodes;
    for (j=0; j<levelTwoArray.length; j++) {
    if (levelTwoArray[j].nodeName.toLowerCase() == "row") {
    myTrace("Node row found and the loopcounter is "+j);
    levelThreeXML = new XML();
    levelThreeArray = new Array();
    levelThreeArray = levelTwoArray[j].childNodes;
    for (w=0; w<levelThreeArray.length; w++) {
    if (levelThreeArray[w].nodeName.toLowerCase() == "name") {
    myTrace("Node name found");
    levelThreeXML = levelThreeArray[w];
    name = trimWithoutTruncate(levelThreeXML.firstChild.nodeV alue);
    myTrace(name);
    }
    if (levelThreeArray[w].nodeName.toLowerCase() == "id") {
    myTrace("Node id found");
    levelThreeXML = levelThreeArray[w];
    id = trimWithoutTruncate(levelThreeXML.firstChild.nodeV alue);
    myTrace(id);
    maritalStatusCode[id] = name;
    myTrace("maritalStatusCode["+id+"] = "+name);
    }
    }
    }
    }
    marLoaded = true;
    // see if it is time to get rid of the LOADING METADATA popup
    metaDataTest();
    }
    }
    //
    // ================================================== ================================================== =============
    // FUNCTION convertEducationXML - grabs all of the education metadata
    // ================================================== ================================================== =============
    //
    function convertEducationXML () {
    if (this.loaded) {
    metaData.canChange = "EDUCATION";
    myTrace("educationXML data loaded. Text parsing beginning.");
    }
    // keep track of following boolean so we know the first number in this array
    firstOneInSequenceFound = false;
    mainTagXML = new XML();
    mainTagXML = this.firstChild.nextSibling;
    if (mainTagXML.nodeName.toLowerCase() == "education") {
    educationCode = new Array();
    levelTwoXML = new XML();
    levelTwoArray = new Array();
    myTrace("First Node education found");
    levelTwoArray = mainTagXML.childNodes;
    for (j=0; j<levelTwoArray.length; j++) {
    if (levelTwoArray[j].nodeName.toLowerCase() == "row") {
    myTrace("Node row found and the loopcounter is "+j);
    levelThreeXML = new XML();
    levelThreeArray = new Array();
    levelThreeArray = levelTwoArray[j].childNodes;
    for (w=0; w<levelThreeArray.length; w++) {
    if (levelThreeArray[w].nodeName.toLowerCase() == "name") {
    myTrace("Node name found");
    levelThreeXML = levelThreeArray[w];
    name = trimWithoutTruncate(levelThreeXML.firstChild.nodeV alue);
    myTrace(name);
    }
    if (levelThreeArray[w].nodeName.toLowerCase() == "id") {
    myTrace("Node id found");
    levelThreeXML = levelThreeArray[w];
    id = trimWithoutTruncate(levelThreeXML.firstChild.nodeV alue);
    if (!firstOneInSequenceFound) {
    // mark the bottom most element of the array
    educationBottomMost = id;
    firstOneInSequenceFound = true;
    }
    myTrace(id);
    educationCode[id] = name;
    myTrace("educationCode["+id+"] = "+name);
    }
    }
    }
    }
    // top most gets the most recent ID
    educationTopMost = id;
    eduLoaded = true;
    // see if it is time to get rid of the LOADING METADATA popup
    metaDataTest();
    }
    }
    //
    // ================================================== ================================================== =============
    // FUNCTION convertIncomeXML - grabs all of the income metadata
    // ================================================== ================================================== =============
    //
    function convertIncomeXML () {
    if (this.loaded) {
    metaData.canChange = "INCOME";
    myTrace("incomeXML data loaded. Text parsing beginning.");
    }
    // keep track of following boolean so we know the first number in this array
    firstOneInSequenceFound = false;
    mainTagXML = new XML();
    mainTagXML = this.firstChild.nextSibling;
    if (mainTagXML.nodeName.toLowerCase() == "income") {
    incomeCode = new Array();
    levelTwoXML = new XML();
    levelTwoArray = new Array();
    myTrace("First Node income found");
    levelTwoArray = mainTagXML.childNodes;
    for (j=0; j<levelTwoArray.length; j++) {
    if (levelTwoArray[j].nodeName.toLowerCase() == "row") {
    myTrace("Node row found and the loopcounter is "+j);
    levelThreeXML = new XML();
    levelThreeArray = new Array();
    levelThreeArray = levelTwoArray[j].childNodes;
    for (w=0; w<levelThreeArray.length; w++) {
    if (levelThreeArray[w].nodeName.toLowerCase() == "name") {
    myTrace("Node name found");
    levelThreeXML = levelThreeArray[w];
    name = trimWithoutTruncate(levelThreeXML.firstChild.nodeV alue);
    myTrace(name);
    }
    if (levelThreeArray[w].nodeName.toLowerCase() == "id") {
    myTrace("Node id found");
    levelThreeXML = levelThreeArray[w];
    id = trimWithoutTruncate(levelThreeXML.firstChild.nodeV alue);
    if (!firstOneInSequenceFound) {
    // mark the bottom most element of the array
    incomeBottomMost = id;
    firstOneInSequenceFound = true;
    }
    myTrace(id);
    incomeCode[id] = name;
    myTrace("incomeCode["+id+"] = "+name);
    }
    }
    }
    }
    // top most gets the most recent ID
    incomeTopMost = id;
    incLoaded = true;
    // see if it is time to get rid of the LOADING METADATA popup
    metaDataTest();
    }
    }
    //
    // ================================================== ================================================== =============
    // FUNCTION convertOccupationXML - grabs all of the occupation metadata
    // ================================================== ================================================== =============
    //
    function convertOccupationXML () {
    if (this.loaded) {
    metaData.canChange = "EDUCATION";
    myTrace("occupationXML data loaded. Text parsing beginning.");
    }
    // keep track of following boolean so we know the first number in this array
    firstOneInSequenceFound = false;
    mainTagXML = new XML();
    mainTagXML = this.firstChild.nextSibling;
    if (mainTagXML.nodeName.toLowerCase() == "job_industry") {
    occupationCode = new Array();
    levelTwoXML = new XML();
    levelTwoArray = new Array();
    myTrace("First Node occupation found");
    levelTwoArray = mainTagXML.childNodes;
    for (j=0; j<levelTwoArray.length; j++) {
    if (levelTwoArray[j].nodeName.toLowerCase() == "row") {
    myTrace("Node row found and the loopcounter is "+j);
    levelThreeXML = new XML();
    levelThreeArray = new Array();
    levelThreeArray = levelTwoArray[j].childNodes;
    for (w=0; w<levelThreeArray.length; w++) {
    if (levelThreeArray[w].nodeName.toLowerCase() == "name") {
    myTrace("Node name found");
    levelThreeXML = levelThreeArray[w];
    name = trimWithoutTruncate(levelThreeXML.firstChild.nodeV alue);
    myTrace(name);
    }
    if (levelThreeArray[w].nodeName.toLowerCase() == "id") {
    myTrace("Node id found");
    levelThreeXML = levelThreeArray[w];
    id = trimWithoutTruncate(levelThreeXML.firstChild.nodeV alue);
    if (!firstOneInSequenceFound) {
    // mark the bottom most element of the array
    occupationBottomMost = id;
    firstOneInSequenceFound = true;
    }
    myTrace(id);
    occupationCode[id] = name;
    myTrace("occupationCode["+id+"] = "+name);
    }
    }
    }
    }
    // top most gets the most recent ID
    occupationTopMost = id;
    occLoaded = true;
    // see if it is time to get rid of the LOADING METADATA popup
    metaDataTest();
    }
    }
    //
    // ================================================== ================================================== =============
    // FUNCTION convertLanguageXML - grabs all of the language metadata
    // ================================================== ================================================== =============
    //
    function convertLanguageXML () {
    if (this.loaded) {
    metaData.canChange = "LANGUAGE";
    myTrace("incomeXML data loaded. Text parsing beginning.");
    }
    // keep track of following boolean so we know the first number in this array
    firstOneInSequenceFound = false;
    mainTagXML = new XML();
    mainTagXML = this.firstChild.nextSibling;
    if (mainTagXML.nodeName.toLowerCase() == "language") {
    languageCode = new Array();
    levelTwoXML = new XML();
    levelTwoArray = new Array();
    myTrace("First Node language found");
    levelTwoArray = mainTagXML.childNodes;
    for (j=0; j<levelTwoArray.length; j++) {
    if (levelTwoArray[j].nodeName.toLowerCase() == "row") {
    myTrace("Node row found and the loopcounter is "+j);
    levelThreeXML = new XML();
    levelThreeArray = new Array();
    levelThreeArray = levelTwoArray[j].childNodes;
    for (w=0; w<levelThreeArray.length; w++) {
    if (levelThreeArray[w].nodeName.toLowerCase() == "name") {
    myTrace("Node name found");
    levelThreeXML = levelThreeArray[w];
    name = trimWithoutTruncate(levelThreeXML.firstChild.nodeV alue);
    myTrace(name);
    }
    if (levelThreeArray[w].nodeName.toLowerCase() == "id") {
    myTrace("Node id found");
    levelThreeXML = levelThreeArray[w];
    id = trimWithoutTruncate(levelThreeXML.firstChild.nodeV alue);
    if (!firstOneInSequenceFound) {
    // mark the bottom most element of the array
    languageBottomMost = id;
    firstOneInSequenceFound = true;
    }
    myTrace(id);
    languageCode[id] = name;
    myTrace("languageCode["+id+"] = "+name);
    }
    }
    }
    }
    // top most gets the most recent ID
    languageTopMost = id;
    // myTrace("top - bottom" + languageTopMost + languageBottomMost);
    lanLoaded = true;
    // see if it is time to get rid of the LOADING METADATA popup
    metaDataTest();
    }
    }
    //
    // ================================================== ================================================== =============
    // FUNCTION convertAccountLoginsXML - grabs all of the logins for the given account
    // ================================================== ================================================== =============
    //
    function convertAccountLoginsXML () {
    if (this.loaded) {
    metaData.canChange = "ACCT LOGINS";
    myTrace("AccountLoginsXML data loaded. Text parsing beginning.");
    }
    myCounter = 0;
    mainTagXML = new XML();
    mainTagXML = this.firstChild.nextSibling;
    if (mainTagXML.nodeName.toLowerCase() == "symbiosis_account_users") {
    educationCode = new Array();
    levelTwoXML = new XML();
    levelTwoArray = new Array();
    myTrace("First Node symbiosis_account_users found");
    levelTwoArray = mainTagXML.childNodes;
    for (j=0; j<levelTwoArray.length; j++) {
    if (levelTwoArray[j].nodeName.toLowerCase() == "account_users") {
    levelThreeXML = new XML();
    levelThreeArray = new Array();
    levelThreeArray = levelTwoArray[j].childNodes;
    for (w=0; w<levelThreeArray.length; w++) {
    if (levelThreeArray[w].nodeName.toLowerCase() == "user") {
    levelFourXML = new XML();
    levelFourArray = new Array();
    levelFourArray = levelThreeArray[w].childNodes;
    selected = "";
    for (p=0; p<levelFourArray.length; p++) {
    if (levelFourArray[p].nodeName.toLowerCase() == "login") {
    levelFourXML = levelFourArray[p];
    name = trim(levelFourXML.firstChild.nodeValue);
    candidateLogin[myCounter] = name;
    myTrace("candidateLogin["+myCounter+"] = "+name);
    }
    if (levelFourArray[p].nodeName.toLowerCase() == "image_url") {
    levelFourXML = levelFourArray[p];
    name = trimForNum(levelFourXML.firstChild.nodeValue);
    candidatePic[myCounter] = name;
    myTrace("candidatePic["+myCounter+"] = "+name);
    myCounter++;
    }
    }
    }
    }
    }
    }
    //
    // call intializeScreen now that we have all the logins and stuff to prepare data for this screen specifically.
    //
    initializeLoginScreen();
    }
    }
    //
    // ================================================== ================================================== =============
    // FUNCTION convertGeneralUserInfoXML - this gets all of the data that is specific to the user once they click START
    // ================================================== ================================================== =============
    //
    function convertGeneralUserInfoXML () {
    if (this.loaded) {
    newText = "...connected";
    myTrace("XML data loaded. Text parsing beginning.");
    }
    mainTagXML = new XML();
    mainTagXML = this.firstChild.nextSibling;
    myTrace("here");
    if (mainTagXML.nodeName.toLowerCase() == "symbiosis_status") {
    levelTwoXML = new XML();
    levelTwoArray = new Array();
    myTrace("First Node symbiosis_status found");
    levelTwoArray = mainTagXML.childNodes;
    for (j=0; j<levelTwoArray.length; j++) {
    if (levelTwoArray[j].nodeName.toLowerCase() == "status") {
    myTrace("Node status found");
    levelTwoXML = levelTwoArray[j];
    status = trim(levelTwoXML.firstChild.nodeValue);
    if (status == "success") {
    otherXML.load("http://www.lemonjello.com/whatever.jsp (returning an XMLfile)");
    newText = "...general data";
    }
    myTrace(status);
    }
    }
    }
    if (mainTagXML.nodeName.toLowerCase() == "symbiosis_user_general") {
    levelTwoXML = new XML();
    levelTwoArray = new Array();
    myTrace("First Node symbiosis_user_general found");
    levelTwoArray = mainTagXML.childNodes;
    for (j=0; j<levelTwoArray.length; j++) {
    if (levelTwoArray[j].nodeName.toLowerCase() == "symbiosis_status") {
    statusXML = new XML();
    statusArray = new Array();
    statusArray = levelTwoArray[j].childNodes;
    for (w=0; w<statusArray.length; w++) {
    if (statusArray[w].nodeName.toLowerCase() == "status") {
    statusXML = statusArray[w];
    status = statusXML.firstChild.nodeValue;
    }
    }
    }
    if (levelTwoArray[j].nodeName.toLowerCase() == "user_general") {
    myTrace("Node user_general found");
    levelThreeXML = new XML();
    levelThreeArray = new Array();
    levelThreeArray = levelTwoArray[j].childNodes;
    for (w=0; w<levelThreeArray.length; w++) {
    if (levelThreeArray[w].nodeName.toLowerCase() == "first_name") {
    myTrace("Node firstname found");
    levelThreeXML = levelThreeArray[w];
    firstName = trim(levelThreeXML.firstChild.nodeValue);
    myTrace(firstName);
    }
    if (levelThreeArray[w].nodeName.toLowerCase() == "middle_name") {
    myTrace("Node middlename found");
    levelThreeXML = levelThreeArray[w];
    middleName = trim(levelThreeXML.firstChild.nodeValue);
    myTrace(middleName);
    }
    if (levelThreeArray[w].nodeName.toLowerCase() == "last_name") {
    myTrace("Node lastname found");
    levelThreeXML = levelThreeArray[w];
    lastName = trim(levelThreeXML.firstChild.nodeValue);
    myTrace(lastName);
    }
    if (levelThreeArray[w].nodeName.toLowerCase() == "dob_month") {
    myTrace("Node dob_month found");
    levelThreeXML = levelThreeArray[w];
    dobMonth = trimForNum(levelThreeXML.firstChild.nodeValue);
    myTrace(dobMonth);
    }
    if (levelThreeArray[w].nodeName.toLowerCase() == "dob_day") {
    myTrace("Node dob_day found");
    levelThreeXML = levelThreeArray[w];
    dobDay = trimForNum(levelThreeXML.firstChild.nodeValue);
    myTrace(dobDay);
    }
    if (levelThreeArray[w].nodeName.toLowerCase() == "dob_year") {
    myTrace("Node dob_year found");
    levelThreeXML = levelThreeArray[w];
    dobYear = trimForNum(levelThreeXML.firstChild.nodeValue);
    myTrace(dobYear);
    }
    if (levelThreeArray[w].nodeName.toLowerCase() == "gender") {
    myTrace("Node gender found");
    levelThreeXML = levelThreeArray[w];
    code = trim(levelThreeXML.firstChild.nodeValue);
    gender = genderStatusCode[code];
    myTrace(gender);
    }
    if (levelThreeArray[w].nodeName.toLowerCase() == "image") {
    myTrace("Node image found");
    levelThreeXML = levelThreeArray[w];
    pic = trimForNum(levelThreeXML.firstChild.nodeValue);
    myTrace("Picture "+pic);
    }
    if (levelThreeArray[w].nodeName.toLowerCase() == "race") {
    myTrace("Node race found");
    levelThreeXML = levelThreeArray[w];
    userRace = trim(levelThreeXML.firstChild.nodeValue);
    myTrace(userRace);
    }
    if (levelThreeArray[w].nodeName.toLowerCase() == "language") {
    myTrace("Node language found");
    levelThreeXML = levelThreeArray[w];
    userLanguage = trim(levelThreeXML.firstChild.nodeValue);
    myTrace(userLanguage);
    }
    if (levelThreeArray[w].nodeName.toLowerCase() == "education_id") {
    myTrace("Node education_id found");
    levelThreeXML = levelThreeArray[w];
    userEducation = trim(levelThreeXML.firstChild.nodeValue);
    myTrace(userEducation);
    }
    if (levelThreeArray[w].nodeName.toLowerCase() == "marital_status_id") {
    myTrace("Node marital_status found");
    levelThreeXML = levelThreeArray[w];
    code = trim(levelThreeXML.firstChild.nodeValue);
    maritalStatus = maritalStatusCode
    Code:
    ;
    						myTrace(maritalStatus);
    					}
    					if (levelThreeArray[w].nodeName.toLowerCase() == "super_user") {
    						myTrace("Node superuser found");
    						levelThreeXML = levelThreeArray[w];
    						superUser = trim(levelThreeXML.firstChild.nodeValue);
    						myTrace(superUser);
    					}
    					if (levelThreeArray[w].nodeName.toLowerCase() == "user_email1") {
    						myTrace("Node emailfound");
    						levelThreeXML = levelThreeArray[w];
    						eMail = trim(levelThreeXML.firstChild.nodeValue);
    						myTrace(eMail);
    					}
    					if (levelThreeArray[w].nodeName.toLowerCase() == "login") {
    						myTrace("Node login found");
    						levelThreeXML = levelThreeArray[w];
    						loginID = trim(levelThreeXML.firstChild.nodeValue);
    						myTrace(loginID);
    					}
    					if (levelThreeArray[w].nodeName.toLowerCase() == "account_name") {
    						myTrace("Node account_name found");
    						levelThreeXML = levelThreeArray[w];
    						accountName = trim(levelThreeXML.firstChild.nodeValue);
    						myTrace(accountName);
    					}
    				}
    				// gottenUserInfo = true;
    				otherXML.load("http://www.lemonjello.com/whatever.jsp  (returning an XMLfile)");
    			}
    		}
    	}
    	if (mainTagXML.nodeName.toLowerCase() == "symbiosis_user_languages_spoken") {
    		levelTwoXML = new XML();
    		levelTwoArray = new Array();
    		myTrace("First Node symbiosis_user_languages_spokenl found");
    		levelTwoArray = mainTagXML.childNodes;
    		for (j=0; j<levelTwoArray.length; j++) {
    			if (levelTwoArray[j].nodeName.toLowerCase() == "symbiosis_status") {
    				statusXML = new XML();
    				statusArray = new Array();
    				statusArray = levelTwoArray[j].childNodes;
    				for (w=0; w<statusArray.length; w++) {
    					if (statusArray[w].nodeName.toLowerCase() == "status") {
    						statusXML = statusArray[w];
    						status = statusXML.firstChild.nodeValue;
    					}
    				}
    			}
    			if (levelTwoArray[j].nodeName.toLowerCase() == "user_languages_spoken") {
    				myTrace("Node user_languages_spoken found");
    				levelThreeXML = new XML();
    				levelThreeArray = new Array();
    				levelThreeArray = levelTwoArray[j].childNodes;
    				for (w=0; w<levelThreeArray.length; w++) {
    					if (levelThreeArray[w].nodeName.toLowerCase() == "row") {
    						myTrace("Node row found");
    						levelFourXML = new XML();
    						levelFourArray = new Array();
    						levelFourArray = levelThreeArray[w].childNodes;
    						selected = "";
    						for (p=0; p<levelFourArray.length; p++) {
    							if (levelFourArray[p].nodeName.toLowerCase() == "selected") {
    								levelFourXML = levelFourArray[p];
    								selected = trimWithoutTruncate(levelFourXML.firstChild.nodeValue);
    							}
    							if (levelFourArray[p].nodeName.toLowerCase() == "id") {
    								levelFourXML = levelFourArray[p];
    								langID = trimForNum(levelFourXML.firstChild.nodeValue);
    							}
    							if (selected == "yes") {
    								userLanguageSpoken = langID;
    								myTrace("okay - finally got it - lang is "+userLanguageSpoken);
    							}
    						}
    					}
    				}
    				// gottenUserInfo = true;
    				otherXML.load("http://www.lemonjello.com/whatever.jsp  (returning an XMLfile)");
    			}
    		}
    	}
    	if (mainTagXML.nodeName.toLowerCase() == "symbiosis_user_occupation") {
    		levelTwoXML = new XML();
    		levelTwoArray = new Array();
    		myTrace("First Node symbiosis_user_occupation");
    		levelTwoArray = mainTagXML.childNodes;
    		for (j=0; j<levelTwoArray.length; j++) {
    			if (levelTwoArray[j].nodeName.toLowerCase() == "symbiosis_status") {
    				statusXML = new XML();
    				statusArray = new Array();
    				statusArray = levelTwoArray[j].childNodes;
    				for (w=0; w<statusArray.length; w++) {
    					if (statusArray[w].nodeName.toLowerCase() == "status") {
    						statusXML = statusArray[w];
    						status = statusXML.firstChild.nodeValue;
    					}
    				}
    			}
    			if (levelTwoArray[j].nodeName.toLowerCase() == "user_occupation") {
    				myTrace("Node user_occupationfound");
    				levelThreeXML = new XML();
    				levelThreeArray = new Array();
    				levelThreeArray = levelTwoArray[j].childNodes;
    				for (w=0; w<levelThreeArray.length; w++) {
    					if (levelThreeArray[w].nodeName.toLowerCase() == "industry_id") {
    						myTrace("Node industry_id found");
    						levelThreeXML = levelThreeArray[w];
    						occID = trimForNum(levelThreeXML.firstChild.nodeValue);
    						userOccupation = occID;
    						myTrace(userOccupation+" is userOccupation");
    					}
    				}
    				gottenUserInfo = true;
    				otherXML.load("http://www.lemonjello.com/whatever.jsp  (returning an XMLfile)");
    			}
    		}
    	}
    	if (mainTagXML.nodeName.toLowerCase() == "symbiosis_account_general") {
    		levelTwoXML = new XML();
    		levelTwoArray = new Array();
    		myTrace("First Node symbiosis_account_general");
    		levelTwoArray = mainTagXML.childNodes;
    		for (j=0; j<levelTwoArray.length; j++) {
    			if (levelTwoArray[j].nodeName.toLowerCase() == "symbiosis_status") {
    				statusXML = new XML();
    				statusArray = new Array();
    				statusArray = levelTwoArray[j].childNodes;
    				for (w=0; w<statusArray.length; w++) {
    					if (statusArray[w].nodeName.toLowerCase() == "status") {
    						statusXML = statusArray[w];
    						status = statusXML.firstChild.nodeValue;
    					}
    				}
    			}
    			if (levelTwoArray[j].nodeName.toLowerCase() == "account_general") {
    				myTrace("Node account_general");
    				levelThreeXML = new XML();
    				levelThreeArray = new Array();
    				levelThreeArray = levelTwoArray[j].childNodes;
    				for (w=0; w<levelThreeArray.length; w++) {
    					if (levelThreeArray[w].nodeName.toLowerCase() == "household_income_id") {
    						myTrace("Node household_income_id");
    						levelThreeXML = levelThreeArray[w];
    						incID = trimForNum(levelThreeXML.firstChild.nodeValue);
    						hhIncome = incID;
    						myTrace(hhIncome+" is hhIncome");
    					}
    					if (levelThreeArray[w].nodeName.toLowerCase() == "rent_own_id") {
    						myTrace("Node rent_own_id");
    						levelThreeXML = levelThreeArray[w];
    						rentOwnID = trimForNum(levelThreeXML.firstChild.nodeValue);
    						currentRentOwnValue = rentOwnStatusCode[rentOwnID];
    						myTrace(rentOwn+" is rentOwn");
    					}
    				}
    				gottenUserInfo = true;
    				// otherXML.load("http://www.lemonjello.com/whatever.jsp  (returning an XMLfile)");
    			}
    		}
    	}
    	if (gottenUserInfo) {
    		newText = "...done";
    		goAhead();
    	}
    }
    // 
    // =================================================================================================================
    // FUNCTION
    // =================================================================================================================
    // 
    function debugtime () {
    	myDate = new Date();
    	return ("- <B>"+myDate.getHours()+":"+myDate.getMinutes()+":"+myDate.getSeconds()+":"+myDate.getMilliseconds()+"</B> - ");
    }
    // 
    // =================================================================================================================
    // FUNCTION
    // =================================================================================================================
    // 
    function trim (bobString) {
    	finalString = "";
    	myArray = new Array();
    	myArray = bobString.split(" ");
    	for (i=0; i<myArray.length; i++) {
    		// if that element of the array is bigger than 1, it means it is not a space and is our candidate!
    		if (myArray[i].length>1) {
    			finalString = myArray[i];
    		}
    	}
    	// have to remove two last characters (not spaces -- I don't know what they are!!!"
    	finalString = finalString.slice(0, finalString.length-2);
    	return finalString;
    }
    // 
    // =================================================================================================================
    // FUNCTION
    // =================================================================================================================
    // 
    function trimWithoutTruncate (bobString) {
    	finalString = "";
    	myArray = new Array();
    	myArray = bobString.split(" ");
    	for (i=0; i<myArray.length; i++) {
    		if (myArray[i].length>1) {
    			finalString = myArray[i];
    		}
    	}
    	return finalString;
    }
    // 
    // =================================================================================================================
    // FUNCTION
    // =================================================================================================================
    // 
    function trimForNum (bobString) {
    	finalString = "";
    	for (i=0; i<bobString.length; i++) {
    		// if that element of the array is a number
    		if (bobString.charAt(i) == "1" || bobString.charAt(i) == "2" || bobString.charAt(i) == "3" || bobString.charAt(i) == "4" || bobString.charAt(i) == "5" || bobString.charAt(i) == "6" || bobString.charAt(i) == "7" || bobString.charAt(i) == "8" || bobString.charAt(i) == "9" || bobString.charAt(i) == "0") {
    			finalString = finalString+bobString.charAt(i);
    		}
    	}
    	return finalString;
    }
    // 
    // =================================================================================================================
    // FUNCTION initializeApplication - will prepare all metadata and clear all vars for whole app
    // =================================================================================================================
    // 
    function initializeApplication () {
    	resetVariables();
    	// 
    	// keeping track of gottenUserInfo so that we know when we can leave the login screen
    	// 
    	gottenUserInfo = false;
    	// 
    	// hardcoding following values because it is too costly to do a http call - change in future
    	// 
    	genderStatusCode = new Array();
    	genderStatusCode[136] = "Male";
    	genderStatusCode[137] = "Female";
    	genderStatusCode[139] = "Unknown";
    	rentOwnStatusCode = new Array();
    	rentOwnStatusCode[186] = "Rent";
    	rentOwnStatusCode[187] = "Own";
    	rentOwnStatusCode[189] = "Unknown";
    	// 
    	// following booleans are to keep track of what metadata has been loaded
    	// 
    	ethLoaded = false;
    	marLoaded = false;
    	eduLoaded = false;
    	incLoaded = false;
    	lanLoaded = false;
    	occLoaded = false;
    	// 
    	// create all the XML objects needed for grabbing of metadata and user info (otherXML is for grabbing the userdata)
    	// 
    	ethnicityXML = new XML();
    	ethnicityXML.onLoad = convertEthnicityXML;
    	ethnicityXML.load("http://www.lemonjello.com/whatever.jsp  (returning an XMLfile)");
    	maritalXML = new XML();
    	maritalXML.onLoad = convertMaritalXML;
    	maritalXML.load("http://www.lemonjello.com/whatever.jsp  (returning an XMLfile)");
    	educationXML = new XML();
    	educationXML.onLoad = convertEducationXML;
    	educationXML.load("http://www.lemonjello.com/whatever.jsp  (returning an XMLfile)");
    	incomeXML = new XML();
    	incomeXML.onLoad = convertIncomeXML;
    	incomeXML.load("http://www.lemonjello.com/whatever.jsp  (returning an XMLfile)");
    	languageXML = new XML();
    	languageXML.onLoad = convertLanguageXML;
    	languageXML.load("http://www.lemonjello.com/whatever.jsp  (returning an XMLfile)");
    	occupationXML = new XML();
    	occupationXML.onLoad = convertOccupationXML;
    	occupationXML.load("http://www.lemonjello.com/whatever.jsp  (returning an XMLfile)");
    	accountLoginsXML = new XML();
    	accountLoginsXML.onLoad = convertAccountLoginsXML;
    	otherXML = new XML();
    	otherXML.onLoad = convertGeneralUserInfoXML;
    }
    // 
    // =================================================================================================================
    // FUNCTION
    // =================================================================================================================
    // 
    function resetVariables () {
    	userAccount = "RobertsonHome";
    	userLogin = "";
    	userPassword = "";
    	verifyPassword = "";
    	candidateLogin = new Array;
    	candidatePic = new Array;
    	firstName = "";
    	middleName = "";
    	lastName = "";
    	dobMonth = "";
    	dobDay = "";
    	dobYear = "";
    	gender = "";
    	userRace = "";
    	userLanguage = "";
    	userEducation = "";
    	maritalStatus = "";
    	superUser = "";
    	eMail = "";
    	pic = 5;
    	autoLogin = "";
    	userOccupation = "";
    	employer = "";
    	title = "";
    	workAddress = "";
    	workZip = "";
    	movieG = "";
    	moviePG = "";
    	moviePG13 = "";
    	movieR = "";
    	movieOther = "";
    	tvY = "";
    	tvY7 = "";
    	tvG = "";
    	tvPG = "";
    	tv14 = "";
    	tvMA = "";
    	accountName = "";
    	streetAddress = "";
    	userState = "";
    	userCountry = "";
    	city = "";
    	zipCode = "";
    	// residence = "";
    	userIncome = "";
    	phoneAreaCode = "";
    	phonePrefix = "";
    	phoneExtension = "";
    	audioHelp = true;
    	myTrace("Variables Reset");
    }
    // 
    // =================================================================================================================
    // FUNCTION
    // =================================================================================================================
    // 
    function myTrace (maty) {
    	if (debug) {
    		trace (maty);
    	}
    }
    // 
    // =================================================================================================================
    // FUNCTION  All the following functions are for the main menu screen
    // =================================================================================================================
    // 
    function timeForWatchTV () {
    	gotoAndPlay ("Regular TV", 1);
    }
    function timeForPersonalSchedule () {
    	gotoAndPlay ("Personal Schedule", 1);
    }
    function timeForProgramSearch () {
    	gotoAndPlay ("Program Search", 1);
    }
    function timeForProfile () {
    	gotoAndPlay ("Snapshot", 1);
    }
    function timeForChangeViewers () {
    	gotoAndPlay ("Login Screen", 1);
    }
    function timeForMainMenu () {
    	gotoAndPlay ("New Main Menu", 1);
    }
    function timeForPreviousScreen () {
    	if (_root.PreviousScreen == "Login Screen") {
    		gotoAndPlay ("Login Screen", 1);
    	}
    	if (_root.PreviousScreen == "Regular TV") {
    		gotoAndPlay ("Regular TV", 1);
    	}
    	if (_root.PreviousScreen == "Guest Login") {
    		gotoAndPlay ("Guest Login", 1);
    	}
    	if (_root.PreviousScreen == "Interests") {
    		gotoAndPlay ("Interests", 1);
    	}
    	if (_root.PreviousScreen == "Profile") {
    		gotoAndPlay ("Profile", 1);
    	}
    	if (_root.PreviousScreen == "Intro") {
    		gotoAndPlay ("Intro", 1);
    	}
    	if (_root.PreviousScreen == "Profile 2") {
    		gotoAndPlay ("Profile 2", 1);
    	}
    	if (_root.PreviousScreen == "Household Profile") {
    		gotoAndPlay ("Household Profile", 1);
    	}
    	if (_root.PreviousScreen == "Profile") {
    		gotoAndPlay ("Profile", 1);
    	}
    	if (_root.PreviousScreen == "Personal Schedule") {
    		gotoAndPlay ("Personal Schedule", 1);
    	}
    	if (_root.PreviousScreen == "Snapshot") {
    		gotoAndPlay ("Snapshot", 1);
    	}
    	if (_root.PreviousScreen == "Program Search") {
    		gotoAndPlay ("Program Search", 1);
    	}
    }
    // 
    // =================================================================================================================
    // FUNCTION initializeLoginScreen - will prepare the data for the screen specifically
    // =================================================================================================================
    // 
    function initializeLoginScreen () {
    	accountTitle = userAccount + " Account"
    	currentBeep = 1;
    	option1.newName = candidateLogin[0];
    	option1.newPic = candidatePic[0];
    	option1.gotoAndPlay("go");
    	option2.newName = candidateLogin[1];
    	option2.newPic = candidatePic[1];
    	option2.gotoAndPlay("go");
    	option3.newName = candidateLogin[2];
    	option3.newPic = candidatePic[2];
    	option3.gotoAndPlay("go");
    	option4.newName = candidateLogin[3];
    	option4.newPic = candidatePic[3];
    	option4.gotoAndPlay("go");
    	// okay now make the first popup disappear
    	gotoAndPlay ("buttons");
    }
    // 
    // =================================================================================================================
    // FUNCTION 
    // =================================================================================================================
    // 
    function updateLoginInfo(clickedUserLogin, clickedUserAutoLogin, clickedUserPassword) {
    	userLogin = clickedUserLogin;
    	userPassword = clickedUserPassword;
    	userAutoLogin = clickedUserAutoLogin;
    	greetings = "Welcome " + userLogin + "!";
    }
    // 
    // =================================================================================================================
    // FUNCTION 
    // =================================================================================================================
    // 
    function guestLogin(){
    	//load the info entered on the Guest Login screen
    	otherXML.load("http://www.lemonjello.com/whatever.jsp  (returning an XMLfile)");
    }

  2. #2
    Junior Member
    Join Date
    Mar 2001
    Posts
    20
    Here is another example -- this one is a modified version of the tutorial here on Flashkit. For some reason, the tutorial on FlashKit didn't work right, but this one does... The only thing you will have to do to get it to work is build the flash page with the right kind of controls...

    Code:
    // create a new xml object
    urlXML = new XML();
    // when the xml data has loaded, we want the XML Object to run the convertXML function
    urlXML.onLoad = convertXML;
    // Write to your text area that the data is loading.
    content_feed_display = "Loading data...";
    // now load up the url.
    urlXML.load("http://p.moreover.com/cgi-local/page?c=Digital%20television%20news&o=xml&n=35");
    
    function convertXML() {
        if(this.loaded) {
            content_feed_display = "Data loaded.";
        }
        mainTag = new XML;
        elementTag = new XML;
        articleList = new Array;
        elementList = new Array;
        mainTag = this.firstChild.nextSibling;
    
    	source_file = this.toString();
    
        if(mainTag.nodeName.toLowerCase() == "moreovernews") {
            articleList = mainTag.childNodes;
            content_feed_display = "";
            for(i=0;i<=articleList.length;i++){
                //initialize a couple of variables to hold xml data we want displayed
                document_url = "";
                headline_text = "";
                if(articleList[i].nodeName.toLowerCase() == "article") {
                    //we get the child node array beneath the articles, aka the meat and potatoes we are after
                    elementList = articleList[i].childNodes;
                    //and loop through that looking for the data we need
                    for(j=0;j<=elementList.length;j++) {
    					//trace("In the loop and j is " + j);
                        elementTag = elementList[j];
                        elementType = elementTag.nodeName.toLowerCase();
                        if(elementType == "headline_text"){
                        headline_text = elementTag.firstChild.nodeValue;
                        } else {
                            if(elementType == "url"){
                                url = elementTag.firstChild.nodeValue;
                            }
                        }
                    }
                content_feed_display += "HTML code" + url + "HTML" + headline_text +"HTML -- need link text and whatnot -- does not show up well in this post so I had to take it out";
                }
            }
        }
    }

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