Reputation: 30158
I'm trying to figure out what's wrong with this code:
for (var k=0;k<2;k++){
var thumb_cols:int = 9;
var thumb_spacing:int = 10; //spaces the clips
project_thumbs_list[k] = myXML.projects.project[k].@thumb;
var projectThumb:thumbClip = new thumbClip();
projectThumb.thumbTitle.text = myXML.projects.project[k].title.toUpperCase();
projectThumb.x = (projectThumb.width + thumb_spacing) * (k % thumb_cols);
projectThumb.y = (projectThumb.width + thumb_spacing) * int(k / thumb_cols);
project_thumbs_array[k] = projectThumb;
var thumbLoader:Loader = new Loader();
thumbLoader.load(new URLRequest(myXML.projects.project[k].@thumb));
thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
}
function thumbLoaded(e:Event):void {
project_thumbs_array[currentLoaded].thumbHolder.addChild(thumbLoader);
admin.slideHolder.addChild(project_thumbs_array[currentLoaded]);
currentLoaded++;
}
I have a sample XML file with two images. If I remove either of the items from the XML, it everything displays fine, but with 2 items in the XML, the first item doesn't show an image, but the second does (maybe the first is being attached in a position behind the second?)
Upvotes: 0
Views: 349
Reputation: 1505
try changing:
project_thumbs_array[currentLoaded].thumbHolder.addChild(thumbLoader);
to:
project_thumbs_array[currentLoaded].thumbHolder.addChild(e.target.data);
might be e.target.content I can't remember off the top of my head.
Upvotes: 1
Reputation: 5381
This should give you 10 pixel horizontal spacing between entities. I didn't address the y-value, but I would recommend taking a look at that as well.
var x_counter = 10;
for (var k=0;k<2;k++){
var thumb_cols:int = 9;
var thumb_spacing:int = 10; //spaces the clips
project_thumbs_list[k] = myXML.projects.project[k].@thumb;
var projectThumb:thumbClip = new thumbClip();
projectThumb.thumbTitle.text = myXML.projects.project[k].title.toUpperCase();
projectThumb.x = x_counter;
projectThumb.y = (projectThumb.width + thumb_spacing);
x_counter = x_counter + projectThumb.width + thumb_spacing;
project_thumbs_array[k] = projectThumb;
var thumbLoader:Loader = new Loader();
thumbLoader.load(new URLRequest(myXML.projects.project[k].@thumb));
thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
}
Upvotes: 0