PDA

View Full Version : loading text file into cur


richtestani
12-22-2005, 06:59 PM
I am trying to load XML data into a text field where some current XML data is previsouly loaded.

I had it so clicking a button would load the data, but it does not replace the data.

how should can get this done?


//create XML instance
var putuXML:XML = new XML();
var putuCSS:TextField.StyleSheet = new TextField.StyleSheet();
//check for load success for CSS
putuCSS.onLoad = function(success) {
if (success) {
trace("yes");
rep_txt.styleSheet = putuCSS;
if (putuCSS.parseCSS(mainText)) {
trace("yes");
} else {
trace("no");
}
} else {
trace("error");
}
};
//ignore returns & tabs
putuXML.ignoreWhite = true;
//check for XML load success
putuXML.onLoad = function(success) {
if (success) {
trace("yes");
parseReps();
} else {
trace("no");
}
};
//load CSS file
putuCSS.load("text/styles.css");
//main XML function parses nodes and displays.
function parseReps() {
var rootNode:XMLNode = putuXML.childNodes[0];
var children:XMLNode = putuXML.childNodes[0].childNodes[0];
var nodeCount:Number = rootNode.childNodes.length;
var childCount:Number = children.childNodes.length;
var a = 0;
for (i=0; i<nodeCount; i++) {
rep_txt.htmlText += '<span class="heading">';
rep_txt.htmlText += rootNode.childNodes[i].childNodes[0].childNodes[0];
rep_txt.htmlText += "</span><br>";
trace(rootNode.childNodes[i].childNodes[i].childNodes[0]);
for (x=0; x<childCount; x++) {
trace(rootNode.childNodes[i].childNodes[x].childNodes[0]);
if (rootNode.childNodes[i].childNodes[x].childNodes[0] == undefined) {
rep_txt.htmlText += '';
} else {
//check if x is 0
//check if city is nodeName
if (rootNode.childNodes[i].childNodes[x].nodeName == "city") {
rep_txt.htmlText += rootNode.childNodes[i].childNodes[x].childNodes[0];
rep_txt.htmlText += ", ";
}
else if(rootNode.childNodes[i].childNodes[x].nodeName == "showroom") {
rep_txt.htmlText += '';
}

else {
rep_txt.htmlText += rootNode.childNodes[i].childNodes[x].childNodes[0];
rep_txt.htmlText += '<br>';
}
}
}
rep_txt.htmlText += '<br>';
}
}
this.putuXML.load("text/repdata.xml");
//button functions
this.scrollDown.onPress = function() {
rep_txt.scroll += 1;
};
this.scrollUp.onRelease = function() {
rep_txt.scroll -= 1;
};
this.shows_btn._alpha = 50;
this.shows_btn.onRelease = function() {
this.rep_btn._alpha = 50;
this.putuXML.load("text/shows.xml");
};
this.shows_btn.onRollOver = function() {
this.shows_btn._alpha = 50;
this.putuXML.load("text/repdata.xml");
};
stop();

richtestani
12-22-2005, 07:28 PM
I am trying to load XML data into a text field where some current XML data is previsouly loaded.

I had it so clicking a button would load the data, but it does not replace the data.

how should can get this done?


//create XML instahttp://www.actionscript.org/forums/images/icons/icon1.gifnce
var putuXML:XML = new XML();
var putuCSS:TextField.StyleSheet = new TextField.StyleSheet();
//check for load success for CSS
putuCSS.onLoad = function(success) {
if (success) {
trace("yes");
rep_txt.styleSheet = putuCSS;
if (putuCSS.parseCSS(mainText)) {
trace("yes");
} else {
trace("no");
}
} else {
trace("error");
}
};
//ignore returns & tabs
putuXML.ignoreWhite = true;
//check for XML load success
putuXML.onLoad = function(success) {
if (success) {
trace("yes");
parseReps();
} else {
trace("no");
}
};
//load CSS file
putuCSS.load("text/styles.css");
//main XML function parses nodes and displays.
function parseReps() {
var rootNode:XMLNode = putuXML.childNodes[0];
var children:XMLNode = putuXML.childNodes[0].childNodes[0];
var nodeCount:Number = rootNode.childNodes.length;
var childCount:Number = children.childNodes.length;
var a = 0;
for (i=0; i<nodeCount; i++) {
rep_txt.htmlText += '<span class="heading">';
rep_txt.htmlText += rootNode.childNodes[i].childNodes[0].childNodes[0];
rep_txt.htmlText += "</span><br>";
trace(rootNode.childNodes[i].childNodes[i].childNodes[0]);
for (x=0; x<childCount; x++) {
trace(rootNode.childNodes[i].childNodes[x].childNodes[0]);
if (rootNode.childNodes[i].childNodes[x].childNodes[0] == undefined) {
rep_txt.htmlText += '';
} else {
//check if x is 0
//check if city is nodeName
if (rootNode.childNodes[i].childNodes[x].nodeName == "city") {
rep_txt.htmlText += rootNode.childNodes[i].childNodes[x].childNodes[0];
rep_txt.htmlText += ", ";
}
else if(rootNode.childNodes[i].childNodes[x].nodeName == "showroom") {
rep_txt.htmlText += '';
}

else {
rep_txt.htmlText += rootNode.childNodes[i].childNodes[x].childNodes[0];
rep_txt.htmlText += '<br>';
}
}
}
rep_txt.htmlText += '<br>';
}
}
this.putuXML.load("text/repdata.xml");
//button functions
this.scrollDown.onPress = function() {
rep_txt.scroll += 1;
};
this.scrollUp.onRelease = function() {
rep_txt.scroll -= 1;
};
this.shows_btn._alpha = 50;
this.shows_btn.onRelease = function() {
this.rep_btn._alpha = 50;
this.putuXML.load("text/shows.xml");
};
this.shows_btn.onRollOver = function() {
this.shows_btn._alpha = 50;
this.putuXML.load("text/repdata.xml");
};
stop();

Cota
12-22-2005, 07:31 PM
Please do not crosspost. Posting the the same question repeatidly will get you ignored.. If some has a solution for you they will let you know..

richtestani
12-22-2005, 07:52 PM
Please do not crosspost. Posting the the same question repeatidly will get you ignored.. If some has a solution for you they will let you know..

Didnt mean to - i noticed my subject line was wrong on my first post and I could not edit it.

Cota
12-22-2005, 07:53 PM
I dont really deal with XML in flash, if not I would help you myself...

richtestani
12-22-2005, 08:06 PM
I dont really deal with XML in flash, if not I would help you myself...

No problem - I appreciate your help on this project however.