I need some help to add a stroke around my images when I load my XML. All the images are getting loaded but they are stacked on top of one another. If I remove the code to add my stroke, then the images load and are spaced out accordingly. I am not sure what I am doing wrong. Can some one help?
var space:int = 10;//space between cells
var w:int = 122;//width of cell
var h:int = 64;//height of cell
var xt:int = 0;
var yt:int = 0;
//create a XML data container that will be the source for the scrollpane
var mcHolder:MovieClip = new MovieClip();
//add container to the scrollpane
scrollBar_mc.addChild(mcHolder);
mcHolder.x = 20;
mcHolder.y = 8;
mcHolder.buttonMode = true;
//set up XML loader to load color list
var myXML:XMLList;
var myLoader:URLLoader = new URLLoader();
myLoader.addEventListener(Event.COMPLETE, xmlLoaded, false, 0, true);
myLoader.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false,0,true);
myLoader.load(new URLRequest("images.xml"));
// Create the xmlLoaded function
function xmlLoaded(event:Event):void {
try {
myXML = XMLList(event.target.data);
myLoader.removeEventListener(Event.COMPLETE, xmlLoaded);
myLoader.removeEventListener(IOErrorEvent.IO_ERROR, onIOError);
//Run the "for each" loop to iterate through all of
//the menu items listed in the external XML file
for each (var pic:XML in myXML..pic) {
var picImage:String = pic.image.toString();
var picloader:Loader = new Loader();
var loadedGraphic:Sprite = new Sprite();
picloader.load(new URLRequest(picImage));
trace(picImage);
picloader.x = xt;
picloader.y = 3;
mcHolder.addChild(picloader);
picloader.contentLoaderInfo.addEventListener(Event.INIT, handleInit);
picloader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded, false, 0, true);
loadedGraphic.addEventListener(MouseEvent.MOUSE_OVER, showHover);
loadedGraphic.addEventListener(MouseEvent.MOUSE_OUT, hideHover);
function handleInit(event:Event):void {
loadedGraphic.addChild(event.target.content as DisplayObject);
//addChild(loadedGraphic);
mcHolder.addChild(loadedGraphic);
loadedGraphic.x = 10;
loadedGraphic.y = 4;
}
function showHover(event:MouseEvent):void {
loadedGraphic.graphics.clear();
loadedGraphic.graphics.beginFill(0x000000);
loadedGraphic.graphics.drawRoundRect(-5, -5, loadedGraphic.width + 10, loadedGraphic.height + 10, 12, 12);
}
function hideHover(event:MouseEvent):void {
loadedGraphic.graphics.clear();
}
//
//set the spacing horizontal
xt = xt+w+space;
}
} catch (err:Error) {
trace("Could not parse loaded content as XML:
" + err.message);
}
}
//complete loaded image
function imageLoaded(event:Event):void {
//trace("loaded");
with (event.target) {
content.smoothing = true;
content.height = 54;
content.width = 103;
}
}
function onIOError(event:IOErrorEvent):void {
trace("An error occured when attempting to load the XML.
" + event.text);
}