View Full Version : XML CDATA.nodeValue = null
simpleSoft
April 12th, 2004, 09:36 PM
Completely at a loss for words...it is there in the xml file. The XML throws no errors. And yet when I try to access the CDATA section it says that its null. What does that mean? Here is my test source, and the link to the location of the XML doc (its a hard coded link in the AS).
Voetsjoeba
April 13th, 2004, 03:29 AM
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function(success) {
if (success && this.status == 0) {
trace("Looping "+this.childNodes[0].childNodes.length+" times.");
for (var i = 0; i<this.childNodes[0].childNodes.length; i++) {
trace(this.childNodes[0].childNodes[i].attributes.title.toString());
sample.text = this.childNodes[0].childNodes[i].firstChild.nodeValue;
trace(sample.text);
}
} else if (!success) {
trace("ERROR LOADING SITE NEWS.");
} else if (this.status != 0) {
trace("ERROR PARSING THE SITE NEWS.");
}
};
xml.load("http://members.cox.net/flashtesterdev/updates/products.xml");
;)
simpleSoft
April 13th, 2004, 08:30 AM
Thanks. Ever feel really stupid? I have.
simpleSoft
April 13th, 2004, 05:37 PM
Ok new question.
Here are the source files (http://members.cox.net/flashtesterdev/test.zip). The question is not so much a question as it is a problem, and the problem is...I cannot get my externally loaded CSS to apply to my text field. Now this isn't a normal text field because I know how to do the simple way. This text field is a item inside of a Movie Clip. And the movie clip has its own class (homePanel.as .:INCLUDED IN THE ZIP FILE:.) and the style sheet is applied via my_mc.setStyle(); look at the method please and tell me what I am doing wrong.
Voetsjoeba
April 14th, 2004, 05:05 AM
I see the problem. The path to the textarea is wrong. You use this inside the onLoad handler, that will target the Stylesheet instance rather than the instance of the class.
homeStyle.onLoad = function(success) {
trace("Loaded style sheet.");
trace(this == homeStyle); //true
this.homeInfo.styleSheet = homeStyle;
};
See what's happening ? You are looking for the textarea inside the Stylesheet instance. Another thing - you are setting homeStyle["owner"] before homeStyle was even created. I don't see why you're using associative array referencing to declare owner - why not just use homeStyle.owner ? That's the same thing, I don't see why you're using homeStyle["owner"].
Anyway, since homeStyle.owner holds a reference to 'this', but still outside the onLoad method, homeStyle.owner refers to the instance of the class. And, inside the onLoad method 'this' is homeStyle, so we end up with this working code:
homePanelAS.prototype.setStyle = function() {
homeStyle = new TextField.StyleSheet();
homeStyle.owner = this;
homeStyle.onLoad = function(success) {
trace("Loaded style sheet.");
this.owner.homeInfo.styleSheet = homeStyle;
};
homeStyle.load("http://members.cox.net/flashtesterdev/updates/style.css");
};
simpleSoft
April 14th, 2004, 08:07 AM
Here is why I don't use homeStyle.owner. I don't know if you use Flash MX 2004 but it has to do with strict data typing. But if you do it your way the compiler throws this errror.
**Error** Scene=Scene 1, layer=ActionScript, frame=1:Line 16: There is no property with the name 'owner'.
But that was it. I kept going back and forth between this.owner & this. but i was declaring it before homeStyle was even made...duh. Many thanks Voets.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.