Why is this array broken?

  • red1000
  • Newbie
  • Newbie
  • User avatar
  • Posts: 12

Post 3+ Months Ago

Hello!

I have an array of 50 movieclips with 5 rows and 10 columns.

Here is how I wanted it to look

and

Here is how it currently looks

I have a flaw in the logic that is repeating the same row over and over, instead of increasing the value correctly.

Any ideas?!

Here is the code:
Code: [ Select ]
//init variables
spacingx = 78;
spacingy = 78;
character._visible = 0;

//open more info
function DisplayInfo() {
  menu_mc._visible = false;
  infobox_mc._visible = true;
  infobox_mc.content_txt.text = this.location_text;
}

//close more info
infobox_mc.close_btn.onRelease = function() {
  menu_mc._visible = true;
  infobox_mc._visible = false;
  infobox_mc.content_txt.text = "";
};

//create character array
infobox_mc._visible = false;
var item_count = 0;
function CreateMenu(menu_xml) {
  var items = menu_xml.firstChild.firstChild.childNodes;
  for (var i = 0; i<items.length; i++) {
   for (var j = 0; j<5; j++) {
     if (items[i].attributes.type == "user") {
      var species = items[i].firstChild;
      var location = items[i].childNodes[1];
      var item_mc = menu_mc.attachMovie("character", "item"+item_count, item_count);
      item_mc._x = spacingx*i;
      item_mc._y = spacingy*j;
      item_count++;
      item_mc.species_txt.text = species.firstChild.nodeValue;
      item_mc.main_btn.location_text = location.firstChild.nodeValue;
      item_mc.main_btn.onRelease = DisplayInfo;
     }
   }
  }
}

//load xml
var feed_xml = new XML();
feed_xml.ignoreWhite = true;
feed_xml.onLoad = function(success) {
  if (success) {
   CreateMenu(this);
  } else {
   trace("Error loading XML file");
  }
};
feed_xml.load("feed.xml");
  1. //init variables
  2. spacingx = 78;
  3. spacingy = 78;
  4. character._visible = 0;
  5. //open more info
  6. function DisplayInfo() {
  7.   menu_mc._visible = false;
  8.   infobox_mc._visible = true;
  9.   infobox_mc.content_txt.text = this.location_text;
  10. }
  11. //close more info
  12. infobox_mc.close_btn.onRelease = function() {
  13.   menu_mc._visible = true;
  14.   infobox_mc._visible = false;
  15.   infobox_mc.content_txt.text = "";
  16. };
  17. //create character array
  18. infobox_mc._visible = false;
  19. var item_count = 0;
  20. function CreateMenu(menu_xml) {
  21.   var items = menu_xml.firstChild.firstChild.childNodes;
  22.   for (var i = 0; i<items.length; i++) {
  23.    for (var j = 0; j<5; j++) {
  24.      if (items[i].attributes.type == "user") {
  25.       var species = items[i].firstChild;
  26.       var location = items[i].childNodes[1];
  27.       var item_mc = menu_mc.attachMovie("character", "item"+item_count, item_count);
  28.       item_mc._x = spacingx*i;
  29.       item_mc._y = spacingy*j;
  30.       item_count++;
  31.       item_mc.species_txt.text = species.firstChild.nodeValue;
  32.       item_mc.main_btn.location_text = location.firstChild.nodeValue;
  33.       item_mc.main_btn.onRelease = DisplayInfo;
  34.      }
  35.    }
  36.   }
  37. }
  38. //load xml
  39. var feed_xml = new XML();
  40. feed_xml.ignoreWhite = true;
  41. feed_xml.onLoad = function(success) {
  42.   if (success) {
  43.    CreateMenu(this);
  44.   } else {
  45.    trace("Error loading XML file");
  46.   }
  47. };
  48. feed_xml.load("feed.xml");


Thanks!
  • red1000
  • Newbie
  • Newbie
  • User avatar
  • Posts: 12

Post 3+ Months Ago

Here is the full source...

I am having a lot of trouble with this, and would love some help!

Thanks!

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 17 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.