Hello all,
I’m trying to make a simple gallery with over lapping images, when clicked I trying to make the selected image change its index value to come to the front. I seem to be hitting a brick wall with ArgumentErrors and RangeErrors…
This is my code
private function xmlLoadedHandler(event:Event):void
{
_xmlObject = new XML(event.target.data);
addChild(container);
var i:uint = 0;
for each(var image:XML in _xmlObject.image)
{
i = i + 1;
var displayImage:ImageDisplay = new ImageDisplay(_xmlPath + image.@src);
container.addChildAt(displayImage, 0);
displayImage.name = "image" + i;
trace(displayImage.name);
displayImage.x = image.@x;
displayImage.y = image.@y;
displayImage.alpha = 0.5;
displayImage.rotation = Math.random() * 15;
displayImage.addEventListener(MouseEvent.CLICK, onMouseEventHandler);
}
trace("There are", container.numChildren, "images in this gallery!");
}
private function onMouseEventHandler(event:MouseEvent):void
{
event.target.setChildIndex(event.target, container.numChildren - 1);
//var circle:Sprite = Sprite(event.target);
//var topPosition:uint = container.numChildren - 1;
//container.setChildIndex(circle, topPosition);
//container.setChildIndex(container.getChildAt(1), 0);
}
I’ve tried a few different ways in the onMouseEventHandler function but so far turned up nothing.
Any help would be appreciated.
Dave