stop(); //trace(_global.UserID); //Generate welcome message using globalVar: dynWelcome.text = "Hello "+_global.User+", please select a following option:"; arrCount = 0; idIndex = 0; _root.onLoad = function() { nextBtn._visible = false; fetchInfo(); }; function fetchInfo() { //Query DB for existing projects: fetchProjects = new LoadVars(); //fetchProjects.userID = _global.UserID; fetchProjects.sendAndLoad("./php/fetchProjects.php", fetchProjects, "POST"); fetchProjects.onLoad = function() { //create arrays to sort data into: projectName = new Array(); projectID = new Array(); var dbResult = fetchProjects.numrows; //sort data into respective arrays: for (arrCount=0, i=1; i<=dbResult; i++, arrCount++) { projectName[arrCount] = fetchProjects["projectName"+i]; projectID[arrCount] = fetchProjects["projectID"+i]; } /* Insert the titles from projectName into the onscreen boxes and the id in the invisible box: */ trace("projectID: "+projectID); for (arrCount=0, i=1; i<=3; arrCount++, i++,idIndex++) { _root["projBtn"+i].projTitle.text = projectName[arrCount]; _root["projBtn"+i].projID.text = projectID[idIndex]; // if the array is empty, clear the boxes. if (_root["projBtn"+i].projTitle.text == "undefined") { _root["projBtn"+i].projTitle.text = ""; _root["projBtn"+i].projID.text = ""; arrCount = 0; idIndex = 0; } //end if } //end forLoop /* If there are more than 4 results then enable the 'more' button: */ if (dbResult>=4) { nextBtn._visible = true; } }; //end onLoad function } //end fetchInfo() nextBtn.onRelease = function() { for (i=1; i<=3; i++) { /* What is going on here: A loop is created that counts to 3 and increments var i. It uses this value to enter the text into the text boxes on the stage and inserts the project title from the projName array, using arrCount as the index value. If incremented arrCount matches the length of the projName then it is reset to zero to allow the projects to be looped in the boxes. If there are less than 3 projects then once an 'undefined' value is returned it is cancelled and nothing appears in the box. */ _root["projBtn"+i].projID.text = projectID[idIndex++]; _root["projBtn"+i].projTitle.text = projectName[arrCount++]; if (arrCount == projectName.length) { arrCount = 0; idIndex = 0; } else if(_root["projBtn"+i].projTitle.text == "undefined") { arrCount = 0; _root["projBtn"+i].projTitle.text = ""; } //endif } };