-
1. Re: Need Some Help with XML Text loading
kglad Jan 2, 2011 8:31 AM (in response to d0brin):
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("sampleXML.xml"));
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
for(var i:uint=0;i<xmlData.children().length();i++){
var tf:TextField=new TextField();
tf.text=xmlData.children()[i];
addChild(tf);
tf.x=whatever
tf.y=whateverelse
}
}
-
2. Re: Need Some Help with XML Text loading
d0brin Jan 2, 2011 8:56 AM (in response to kglad)yes but this way it doesnt load in the designated text field with instance name tf1. but creates a new text field... :S with small font size, small text field width and it seems like it loads all the lines of the XML one over another... how to make it since i have 4 text fields designated on the main stage the text from the XML to go to them...
-
3. Re: Need Some Help with XML Text loading
kglad Jan 2, 2011 9:14 AM (in response to kglad)adjust the code to your specific situation. the answer to your question is in the above code using the children() method of your xmllist.
if you need help with your specific situation beyond how to parse your xml, you'll need to explain your specific situation.
-
4. Re: Need Some Help with XML Text loading
d0brin Jan 2, 2011 9:17 AM (in response to kglad)well here is the situation:
I have 4 text fields, styled with font and font size. Also they are dynamic text fields with isntance names tf1.tf2,tf3,tf4 and set to use Device Fonts.
What i want is those 4 lines from the XML to go to the 4 text fields on the stage. Where 1 line goes to 1 text field.
-
5. Re: Need Some Help with XML Text loading
kglad Jan 2, 2011 9:19 AM (in response to kglad)if those textfields already exist when your code executes you can use:
var tl:MovieClip=this;
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("sampleXML.xml"));
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
for(var i:uint=0;i<xmlData.children().length();i++){
tl["tf"+(i+1)].text=xmlData.children()[i];
}
}
-
6. Re: Need Some Help with XML Text loading
d0brin Jan 2, 2011 9:24 AM (in response to kglad)thanks it helped me a lot
-
7. Re: Need Some Help with XML Text loading
kglad Jan 2, 2011 9:34 AM (in response to d0brin)you're welcome.



