Hello all, I am new with ActionScript but not entirely new to programming so I haven’t had many problems with it. However I am trying to make a slideshow like slide.com’s. I have 3 layers:
Actionscript
Preloader
Images
This is the ActionScript in the Images layer:
stop();
import flash.display.*;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.xml.*;
import flash.events.*;
function loadXML() {
var uLoader:URLLoader = new URLLoader();
var id:int = root.loaderInfo.parameters.id;
uLoader.addEventListener(ProgressEvent.PROGRESS, onXMLProgress);
uLoader.addEventListener(Event.COMPLETE, onXMLLoaded);
uLoader.load(new URLRequest('images.xml'));
}
function onXMLProgress(event:ProgressEvent):void {
trace('Loaded: ' + event.bytesLoaded, 'Total: ' + event.bytesTotal);
}
function onXMLLoaded(event:Event):void {
gotoAndStop(2);
var loader:URLLoader = URLLoader(event.target);
var _xml:XML = new XML(loader.data);
var images:XMLList = _xml..image;
var x_position:int;
var y_position:int;
var w:int;
var h:int;
var i:int;
var thumbnail:Loader;
w = 1;
h = 1;
for each(var image:XML in images) {
x_position = 75 * w;
y_position = 20 + (85 * h) - 85;
thumbnail = new Loader();
thumbnail.load(new URLRequest(image.path.toString()));
thumbnail.x = x_position;
thumbnail.y = y_position;
thumbnail.name = 'thumbnail_' + i;
trace('title: ' + image.title.toString());
trace('x: ' + x_position);
trace('y: ' + y_position);
w++;
h++;
i++;
if (w % 6 == 0) {
w = 0;
}
if (h % 4 == 0) {
h = 0;
}
}
}
loadXML();
On the stage there is 20 pixels before the thumbnails are supposed to be layed out, so I have tried to accommodate this. So the objects I want to create are the thumbnails. My problem is they are not showing up, and I have a valid image URL in the XML. Can anyone tell me how I would fix this? How do I do this in AS3? Thank you for all the help.