Need Help with For Loop structure

  • CStrauss
  • Graduate
  • Graduate
  • User avatar
  • Posts: 122
  • Loc: St. Louis MO. USA

Post 3+ Months Ago

I'm playing around with bringing image data in from a database using AMFPHP. Im still learning how to work with amfPHP and apparently it brings in the data as multidemensional array. So I have to now split that up into individual arrays I think so i can access them when need in AS3.

This is how i have my arrays set up in AS
Code: [ Select ]
// set up arrays to be used
var imagePath:Array=[];
var imageTitle:Array=[];
var imageDesc:Array=[];
var imageDate:Array=[];
  1. // set up arrays to be used
  2. var imagePath:Array=[];
  3. var imageTitle:Array=[];
  4. var imageDesc:Array=[];
  5. var imageDate:Array=[];


now I can right a for loop if there was only one element in the array but when there are several values I'm having trouble getting the structure right to store properly in the above arrays.

Can anyone type up a sample code of a for loop needed so i can look at it and see what I'm typing wrong?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

this is AS2 but I don't think loops are too different in AS3

Typical loop for each item in an array assuming all array's have the same number of items.
Code: [ Select ]
for(i=0;i<arrayname.length;i++){
    var path = imagePath[i]; // where path becomes the value in the array at i
// same with other arrays
}
  1. for(i=0;i<arrayname.length;i++){
  2.     var path = imagePath[i]; // where path becomes the value in the array at i
  3. // same with other arrays
  4. }
  • CStrauss
  • Graduate
  • Graduate
  • User avatar
  • Posts: 122
  • Loc: St. Louis MO. USA

Post 3+ Months Ago

thanks I got it for some reason i was thinking i need four different for loops but I didn't. But I believe your right they didn't change the loop and other conditional statements in AS3 at least as far as I know they didnt. But thanks for the help
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

no problem. good luck.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 5 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.