I am having trouble trying to call this whole routine (again) once a 'save button' is clicked (basically want to re-populate to reflect changes)
this already gets called ONCE (intitally) on the movie/project Load...
1.) I have tried to wrap the whole thing (routine) in a function, but then it stops working as it should (doesnt populate correctly, everything becomes 'undefined')
2.) I have tried pathing to the specific functions from my save button (located on _root)...but no go...(failed load)
here is the code (all of it) I need to 're-call' and run, when the save button is clicked.
thanks for anything I am missing:
Code:import mx.utils.Delegate; // var rootNode:XMLNode; var productsNode:Array; var totalProducts:Number; var myProducts_xml = new XML(); // myProducts_xml.ignoreWhite = true; myProducts_xml.onLoad = Delegate.create(this, getTotalProducts); myProducts_xml.load("prodData/products.xml"); //local version //myProducts_xml.load("prodData/products.xml?ran="+random(999999)); //web version (cache killer) // function getTotalProducts(success):Void { if (success == true) { rootNode = myProducts_xml.firstChild; productsNode = rootNode.childNodes; totalProducts = rootNode.childNodes.length; createProducts(); this.onEnterFrame = Delegate.create(this, function() { populateAll(); delete this.onEnterFrame; }//end Function ); //end Delegate }else { trace("INIITIAL Load Failed"); } } // function createProducts():Void { //Define how many columns var columns:Number = 1; //Define the item vSpacing; var vSpacing:Number = 10; //Define the item hSpacing; var hSpacing:Number = 0; for (i=0; i<totalProducts; i++) { var attachProduct:MovieClip = attachMovie("productEntry", "product"+i, i); attachProduct._x += 10; attachProduct._y += 0; attachProduct._y += i * 45; //attachProduct._y = Math.floor(i / columns) * hSpacing; //only used with multiple columns //attachProduct._x = Math.floor(i % columns) * vSpacing; //only used with multiple columns } } //populate function populateAll():Void { for (i = 0; i < totalProducts; i++) { var totalQuantity:Number =productsNode[i].childNodes[7].childNodes.length; //random data var obj = this["product" + i]; obj.prodNum = i; //declaring what product (node) this is //currentImage var prodImage:String = productsNode[i].childNodes[0].firstChild.nodeValue; var obj = this["product" + i]; obj.currentImage = prodImage; //obj.currentImage = obj.currentImage.toUpperCase(); obj.currentImage = obj.currentImage.toLowerCase(); //name var prodName:String = productsNode[i].childNodes[1].firstChild.nodeValue; var obj = this["product" + i]; obj.name_txt.text = prodName +i; obj.name_txt.text = obj.name_txt.text.toUpperCase(); //price var prodPrice:Number = productsNode[i].childNodes[2].firstChild.nodeValue; var obj = this["product" + i]; obj.selectedPrice = ["$"+prodPrice]; obj.price_txt.text = obj.selectedPrice; //trace("PRICE :"+obj.selectedPrice); //description var prodDesc:String = productsNode[i].childNodes[5].firstChild.nodeValue; var obj = this["product" + i]; obj.descriptionVar = prodDesc; obj.descriptionVar = obj.descriptionVar.toUpperCase(); //obj.descriptionVar = obj.descriptionVar.toLowerCase(); //colors var colorLength:Number =productsNode[i].childNodes[4].childNodes.length; trace("Total Colors: "+colorLength); for (z = 0; z < colorLength; z++) { var totalColors:Array =productsNode[i].childNodes[4].childNodes[z].firstChild.nodeValue; var obj = this["product" + i]; obj.colorChoices.push(totalColors); } //sizes var sizeLength:Number =productsNode[i].childNodes[3].childNodes.length; trace("Total Sizes: "+sizeLength); for (y = 0; y < sizeLength; y++) { var totalSizes:Array =productsNode[i].childNodes[3].childNodes[y].firstChild.nodeValue; var obj = this["product" + i]; obj.sizeChoices.push(totalSizes); } trace("Color Array: "+obj.colorChoices); trace("Size Array: "+obj.sizeChoices); trace(newline); } }


Reply With Quote
