|
|
|
#1 |
|
Moderator
Join Date: Mar 2001
Location: CFA2h (respect the HEX)
Posts: 11,647
|
call function from another scope (delegate)
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);
}
}
__________________
preloader 1 2 3 4 | pop-up help | play-by-variable | dynamic anchors | slow motion | asfunction | text scroller 1 2 | pause | embed dynamic images | yahoo! maps 1 2 | paypal 1 2 | resize broswer | attachClip 1 2 | embedVar > flash | urlVar > flash 1 2 3 varObject | textFile-by-date | fake expire | save-2-text | reverse 1 2 | sharedObject 2 | xml 101 | resetBrowserSB | fullScreen z-index | resize flash 1 2 | deepLink | clipLoader | toggle | ip | setTimeout |
|
|
|
|
|
#2 |
|
frankenmoderator
Join Date: Aug 2002
Location: Indiana/Maryland
Posts: 2,988
|
So you want to run this part of the top of the code again?
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)
//
|
|
|
|
|
|
#3 |
|
Moderator
Join Date: Mar 2001
Location: CFA2h (respect the HEX)
Posts: 11,647
|
HOORAY!...someone is here...I was just about to call it quits..
I try right now... now it does even initially run/ececute.. ![]() Code:
function intialRead() {
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("http://www.dmstudios.net/flashCart_final/prodData/products.xml"); //local version
//myProducts_xml.load("prodData/products.xml?ran="+random(999999)); //web version (cache killer)
}
//call above initialRead(); function
initialRead();
//
![]() I'd hate to have to resort to a COMPLETE page refresh... this darn Delegate.create function has been the BANE of my exsistence since I found out about it!! LOL I wouldnt mind sending yout he WHOLE project (if need be)...but its pretty big...and Im sure noone codes the same..and its always a task to debug others work... but I really dont know how to excute that code again. it reside in a several time over nexted clip (frame 1) that executes when the movie loads.... what I need to do is run that again from a button on _root. and I have seriously tried a million way sof pathing..recalling the Delegate funtion over, from different scopes...etc..etc.. Im dead in the water...
__________________
preloader 1 2 3 4 | pop-up help | play-by-variable | dynamic anchors | slow motion | asfunction | text scroller 1 2 | pause | embed dynamic images | yahoo! maps 1 2 | paypal 1 2 | resize broswer | attachClip 1 2 | embedVar > flash | urlVar > flash 1 2 3 varObject | textFile-by-date | fake expire | save-2-text | reverse 1 2 | sharedObject 2 | xml 101 | resetBrowserSB | fullScreen z-index | resize flash 1 2 | deepLink | clipLoader | toggle | ip | setTimeout |
|
|
|
|
|
#4 |
|
Moderator
Join Date: Mar 2001
Location: CFA2h (respect the HEX)
Posts: 11,647
|
UPDATE:
ok..I had a typo... in the function name (corrected, should be initialRead() ..) anyways...so it is NOW getting hung up on the other Delegates I believe... as this trace fires: Code:
function getTotalProducts(success):Void {
trace("getTotalProducts Called");
no products ..nothing populates still..
__________________
preloader 1 2 3 4 | pop-up help | play-by-variable | dynamic anchors | slow motion | asfunction | text scroller 1 2 | pause | embed dynamic images | yahoo! maps 1 2 | paypal 1 2 | resize broswer | attachClip 1 2 | embedVar > flash | urlVar > flash 1 2 3 varObject | textFile-by-date | fake expire | save-2-text | reverse 1 2 | sharedObject 2 | xml 101 | resetBrowserSB | fullScreen z-index | resize flash 1 2 | deepLink | clipLoader | toggle | ip | setTimeout |
|
|
|
|
|
#5 |
|
Moderator
Join Date: Mar 2001
Location: CFA2h (respect the HEX)
Posts: 11,647
|
Dricciotti-
I loose ya? Any ideas?
__________________
preloader 1 2 3 4 | pop-up help | play-by-variable | dynamic anchors | slow motion | asfunction | text scroller 1 2 | pause | embed dynamic images | yahoo! maps 1 2 | paypal 1 2 | resize broswer | attachClip 1 2 | embedVar > flash | urlVar > flash 1 2 3 varObject | textFile-by-date | fake expire | save-2-text | reverse 1 2 | sharedObject 2 | xml 101 | resetBrowserSB | fullScreen z-index | resize flash 1 2 | deepLink | clipLoader | toggle | ip | setTimeout |
|
|
|
![]() |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|