Welcome, Guest. Please login or register.
Did you miss your activation email?
02/08/12, 07:46
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  Web Services: XML, Soap, WSDL, UDDI, and Flash Integration (Moderators: Flash-db, Musicman, vesa kortelainen, Ronald Wernecke, Jorge Solis)
| | |-+  FOR LOOP PROBLEM
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: FOR LOOP PROBLEM  (Read 3729 times)
bAtUsay_sheng
Server what's that
*
Posts: 24


View Profile Email
« on: 07/09/07, 23:24 »

Greeting guys! i have simple problem in my for loop..I want to increase the incrementation in loop everytime i press a button..So that i can get the attribute value of color and number by element not all at once. How can i declare it in my for loop that every i press a certain button that's the only time the variable i:Number will increase here is the code..

var xFile:XML = new XML();
xFile.ignoreWhite = true;

xFile.onLoad = function(bSuccess:Boolean){
if(bSuccess){
var xnParentNode:XMLNode = this.firstChild;
var xnItem:XMLNode;
var xnTitle:XMLNode;
var sXMLColor:String;
var sXMLNumber:String;
for(var i:Number = 0; i < xnParentNode.childNodes.length; i++){
xnItem = xnParentNode.childNodes;
sXMLColor = xnItem.attributes.color;
sXMLNumber = xnItem.attributes.number;
}
} else{
trace("Load Error");
}
}
xFile.load("XML_data.xml");


should i also paste my xml file also..?
Thanks... Hopin you could help me guys..
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14593


View Profile
« Reply #1 on: 07/10/07, 01:22 »

Write a function and pass the index as parameter:

function getNode(index){
  var 
xnParentNode:XMLNode this.firstChild;
   var 
xnItem:XMLNode;
   var 
xnTitle:XMLNode;
   var 
sXMLColor:String;
   var 
sXMLNumber:String;
    
xnItem xnParentNode.childNodes[index];
    
sXMLColor xnItem.attributes.color;
     
sXMLNumber xnItem.attributes.number;
    .....
}

Jorge
Logged

bAtUsay_sheng
Server what's that
*
Posts: 24


View Profile Email
« Reply #2 on: 07/10/07, 20:55 »

thanks men!
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!