Avatar of lowsky13
lowsky13
 asked on

getting individual values from array

I have information in an array. It traces out. However, how do I call just one at a time? I have file locations to call photos for my loader. I want them to load individually not as a whole list. How do I split them up? Also, how do I get the number of items I have in my array? I have tried "length" but that only gave me the total characters..not the number of items.

I'm using AS3.
Adobe FlashScripting Languages

Avatar of undefined
Last Comment
go4ejjohn

8/22/2022 - Mon
go4ejjohn

I think what you have is a string not array.
firstly you should convert string in to array.
var str = old_str.split(",");

here old_str is the string what u think it as an array.
str is an array you can then get the length of an array.

Regards,
Jon
lowsky13

ASKER
i figured out how to get the length of the array. i cannot now figure out how to split the array into individual values...below is my code.

picnumber is how many items there are and ppic are all the values. I need to be able to get individual values...

I want to load the first value into my loader...then if I click a button have it load the next one and/or go to the previous. How would I go about that? Isn't ppic already in an array?
//connect to xml file
var photoArray:Array;
var xmlConnect:URLLoader = new URLLoader();
var xmlData:XML = new XML();
 
xmlConnect.addEventListener(Event.COMPLETE, LoadXML);
 
xmlConnect.load(new URLRequest("xml.xml"));
 
function LoadXML(e:Event):void {
 
xmlData = new XML(e.target.data);
loadData(xmlData);
 
}
 
function loadData(playlist:XML):void {
	var picnumber:Number = playlist.listitem.ppic.length();
	var ppic:String = playlist.listitem.ppic.text();
 
//put photos into an array

Open in new window

go4ejjohn

ppic is a string and i can C it clearly in your declaration. can you trace ppic for me?

Regards,
Jon
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
lowsky13

ASKER
A trace of ppic outputted my two values butted up against each other. Also traced picnumber and got 2. So they are both tracing correctly. I just need to be able to get each value dynamically.
go4ejjohn

hey tell me what is the output when you trace ppic ?

Jon
lowsky13

ASKER
I don't see why you need the exact results because the content doesn't matter but it is..

string1string2

This is correct but I need to know how to call string2 independent of string1. My xml files will constantly change so it needs to be dynamic.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
go4ejjohn

Is there a way that you can get your out put
string1,string2 format (that is with a , seperated)?

Jon
lowsky13

ASKER
I have done this but I get the same result...no comma or anything broken up...also no errors though. What do you suggest?
//put photos into an array
 
var str = ppic.split(",");
trace(str);

Open in new window

go4ejjohn

Could you please show me your XML file..

Jon
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
go4ejjohn

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.