I am having a little trouble adding my pics to the scroll pane. I can get my captions to load, although they are all stacked on top of one another. Tracing the thumbPic variable gives for example: /gallery/trucks/tn/action_1.jpg but my attempts to add the image doesn’t seem work.
Any help appreciated.
my XMl file looks like this:
<images>
<pic>
<image>/gallery/trucks/tn/action_1.jpg</image>
<caption>Action One</caption>
</pic>
<pic>
<image>/gallery/trucks/tn/action_2.jpg</image>
<caption>Action Two</caption>
</pic>
<pic>
<image>/gallery/trucks/tn/dump_1.jpg</image>
<caption>Dump 1</caption>
</pic>
<pic>
<image>/gallery/trucks/tn/dump_2.jpg</image>
<caption>Dump 2</caption>
</pic>
</images>
// create a movie clip to be the source for the scroll pane
var imageHolder:MovieClip = new MovieClip();
addChild(imageHolder);
//create a scrollPane and load the imageHolder into the scrollPane
var imagePane:ScrollPane = new ScrollPane();
imagePane.setSize(320, 120);
imagePane.move(10, 230);
imagePane.source = imageHolder;
addChild(imagePane);
//load XML file
//set up XML loader
var imagesXML:XMLList = new XMLList();
var xmlURL:String = "images.xml";
var myXMLURL:URLRequest = new URLRequest(xmlURL);
var xmlLoader:URLLoader = new URLLoader(myXMLURL);
xmlLoader.addEventListener("complete", xmlImagesLoaded, false, 0, true);
function xmlImagesLoaded(event:Event):void {
imagesXML = XMLList(xmlLoader.data);
for each (var pic:XML in imagesXML..pic) {
var thumbPic:String = pic.image.toString();
var thumbCaption:String = pic.caption.toString();
trace(thumbPic);
trace(thumbCaption);
//var box:MovieClip = new MovieClip();
//box.addChild(thumbPic);
var myText1:TextField = new TextField();
//format text
var format:TextFormat = new TextFormat();
format.font = "Arial";
format.size = 12;
format.kerning = 0;
//format.align = TextFormatAlign.LEFT;
myText1.defaultTextFormat = format;
myText1.text = thumbCaption;
myText1.autoSize = TextFieldAutoSize.LEFT;
//imageHolder.addChild(box);
imageHolder.addChild(myText1);
}
}