Skip to main content
October 7, 2009
Answered

Two part question.... Scrolling multiple text fields via 1 scroll bar. Removing commas from being displayed in array list.

  • October 7, 2009
  • 1 reply
  • 405 views

I have been scripting this flash profile card which pulls data from multiple XML files. The problem i am having is when it comes down to pulling this 1 set of information which is accessing the attributes of an array of specific XML nodes on display after the first item it inputs a comma before each item.

My code:

-------------------------------------------------------------------------

xmlData = new XML ();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load ("../xml profiles/test.xml");

--------------------------------------------------------------------------

function loadXML (loaded)
{
if (loaded)
{
  xmlNode = this.firstChild;

  image = [];

  id_array = [];
  total = xmlNode.childNodes.length;
  for (i = 0; i < total; i++)
  {

image = "../people/photos/" + xmlNode.childNodes.childNodes[1].firstChild.nodeValue + ".jpg";

id_array = xmlNode.childNodes.childNodes[10].childNodes;
  }
  firstImage ();
}
else
{
  content = "file not loaded!";
}

-------------------------------------------------------------------------
}

function firstImage ()
{
if (loaded == filesize)
{
  picture._alpha = 0;
  picture.loadMovie (image[0],1);
  associate_array = id_array[0];
  populateLists (associate_array);
  picture_num ();
}
}

---------------------------------------------------------------------

function populateLists (xml_array)
{
identification = [];
associatelist = [];
locationlist = [];
for (n = 0; n < xml_array.length; n++)
{
  var identnumber = xml_array.attributes;
  identification = identnumber.occurence + "\n";
  associatelist = identnumber.associate + "\n";
  locationlist = identnumber.Location + "\n";
  occurence_txt.text = identification;
  associate_txt.text = associatelist;
  location_txt.text = locationlist;
}
}

The red code is the data being displayed with commas after the first item. I could not find a solution anywhere... but saw discussion about nested arrays commonly displaying commas.

This is just a draft version of the layout i used to pull up fake data... to show the commas.

If anyone knows how to remove the commas that would be great.

Lastly i am wondering if it is possible to control the 3 text fields using 1 scroll bar or would i be better off learning how to create columns in 1 text field to display these lists.

Thanks in advance!

...some day i will need to learn AS3

This topic has been closed for replies.
Correct answer shintashi

i don't have a clue about the XML (I'm still in embryo stage on that one at one-half a tutorial) BUT,

to connect without commas, you can do something like this. My array name was aHiragana (japanese letters)

   
var sHiragana:String = aHiragana.join(""); //kills the comma
words.text = sHiragana.toString(); //works, note "s" not "a" infront of Hiragana.

no idea if this is compatible with XML.

1 reply

shintashiCorrect answer
Inspiring
October 7, 2009

i don't have a clue about the XML (I'm still in embryo stage on that one at one-half a tutorial) BUT,

to connect without commas, you can do something like this. My array name was aHiragana (japanese letters)

   
var sHiragana:String = aHiragana.join(""); //kills the comma
words.text = sHiragana.toString(); //works, note "s" not "a" infront of Hiragana.

no idea if this is compatible with XML.

October 7, 2009

Thank you so much!

This totally solved the "comma" issue.

Now i just need to find out if it is possible to control the scroll of all 3 text fields by using only 1 UIscrollbar component.