actionscript 3 - How to arrange images with coordinates given from xml? -
good day, have question. need use loop arrange loaded images xml. how should load in function loaddata images it's coordinates(x,y) , description textfields ?? here code:
var xmllist:xmllist; var urlloader:urlloader; function main():void { urlloader = new urlloader(); urlloader.load(new urlrequest("images.xml")); urlloader.addeventlistener(event.complete, loaddata); } function loaddata(e:event):void { xml = new xml(urlloader.data); xmllist = xml.image; (var i:uint = 0; < xmllist.length(); ++ ) { }}
here xml:
<images> <image> <title>first picture</title> <file>images/pic1.jpg</file> <x>180</x> <url></url> <y>50</y> </image> <image> <title>second picture</title> <file>images/pic2.jpg</file> <x>100</x> <y>100</y> <url></url> </image>
lot!
looking @ code suggest use tilelist display images. than, can build custom component use itemrenderer in order result want. if don't want use list display images, have create custom component can display image + text , use xy attributes of component position on screen.
it this:
` var mycomp:mycustomcomponent;
for (var i:uint = 0; < xmllist.length(); ++ ) { mycomp = new mycustomcomponent(); targetui.addchild(mycomp); mycomp.text = xmllist..image[i].title; mycomp.imgsrc = xmllist..image[i].file; mycomp.x = xmllist..image[i].x; mycomp.y = xmllist..image[i].y; }
`
hope helps!
Comments
Post a Comment