You must be logged in to post Login Register
Search 

arranging images of varying width with XML

User Post

11:20 am
June 16, 2009


gregtpp

Member

posts 4

1

Post edited 8:33 pm – June 16, 2009 by gregtpp


I am trying to organize a series of images horizontally on my site. All the tutorials I find about image galleries utilize image thumbnails of the same width. I want to be able to use images of varying widths but cannot figure out how the ActionScript should be set up to handle this.


This is the piece of the code that handles the XML file.


function processXML (e:Event):void {

var myXML:XML = new XML(e.target.data);

my_x =

my_y =

my_img_height =

my_images = myXML.IMAGE;

my_total = my_images.length();

createContainer();

callImages();

masking();

scrollbar();

scroller();

}

and in the XML file I put WIDTH as an Attribute of each IMAGE tag.

such as 


What I can't figure out is in the CallImages function how I do the math to stack the images horizontally.

function callImages():void {

for (var i:Number = 0; i < my_total; i++) {

var img_url = my_images[i].@IMG;

var imgWidth = my_images[i].@WIDTH;

var img_loader = new Loader();

img_loader.load(new URLRequest(img_url));

img_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaded);

img_loader.name = i;

var thumbPosition:Number = 0;

img_loader.x = thumbPosition; 

thumbPositiona = ((imgWidth)*1)+thumbPosition; 

thumbPosition = (Number(thumbPositiona)+10); 

}

Not really sure how I go about adding the widths together. All attempts I've made so far just stack the images one on top of another. Can anyone lend any assistance.

Thank you

Topic RSS 
Search