|
-
May 21st, 2009, 07:40 PM
#1
[RESOLVED] XML: Get length of file
Hi,
How would I get the length of an xml file? I need to figure out how much data is in the xml file so it can be use on the end of a condition for a "For" statement.
Thanks,
Nightwalker
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
May 22nd, 2009, 04:24 PM
#2
Re: XML: Get length of file
What do you mean by length? Something like Len(xml file)? If so then you could probably use the FSO to open and read the contents into a varabale and then use the Len function but I'm guessing there would be a better way of accomplishing what you want to do. What are you using the for loop for?
-
May 22nd, 2009, 07:16 PM
#3
Re: XML: Get length of file
I have an xml file full of data, I am looking to retrieve the label tags within then file so I can use them in a Flash Action Script 3.0 for loop to apply the same settings to all of the buttons on the stage.
In the xml file:
Code:
<?xml version="1.0"?>
<menu>
<font>verdana</font>
<color>0x009900</color>
<size>20</size>
<menuLabels>
<label>Home</label>
<label>About</label>
<label>Products</label>
<label>Admin Login</label>
<label>Customers</label>
</menuLabels>
</menu>
Flash file:
Code:
var buttonArray:Array = new Array();
var tField: TextField = new TextField();
var tformat: TextFormat = new TextFormat();
var req: URLRequest = new URLRequest("menuDef.xml");
var loader:URLLoader = new URLLoader(req);
var myXML:XML = new XML();
myXML.ignoreWhite = true;
loader.load(req);
loader.addEventListener(Event.COMPLETE,dataLoaded);
//Button code
function dataLoaded (event:Event){
myXML = new XML(loader.data);
tformat.color = myXML.color;
tformat.size = myXML.size;
tformat.font = myXML.font;
}
var ButtonArray:Array = new Array ("Home");
var btn:MovieClip = new MovieClip ()
for each (btn in ButtonArray) {
btn.addChild(tField)
}
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
May 28th, 2009, 07:42 PM
#4
Re: XML: Get length of file
I figured out the solution!
Code:
var req: URLRequest = new URLRequest("menuDef.xml");
var loader:URLLoader = new URLLoader(req);
var i:int
var myXML:XML = new XML();
loader.load(req);
loader.addEventListener(Event.COMPLETE,dataLoaded);
//Button code
function dataLoaded (event: Event){
myXML = new XML(loader.data);
for (i = 0; i < 5; i++){
var j:int = i+ 1;
/**3 is the line in the
xml the labels start from. (i) starts counting from the 4th line until the end
specified above.**/
this["btnMenu"+ j].btText.text = myXML.child(3).child(i);
}
}
If the items in your xml file are more or less than "5" change the number to suit.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|