centering an image in a viewstack in actionscript
This was much more difficult than it should've been to figure out, but there's a simple solution.
I have a viewstack element and I am programmatically creating a slideshow by changing viewStack.selectedIndex on a timer.
Each image for the slideshow is wrapped in a canvas element. The trick was to use setStyle to set horizontalCenter & verticalCenter on the image.
Here's the code:
var canvas:Canvas = new Canvas();
var image:Image = new Image();
image.source = src;
canvas.addChild(image);
image.setStyle("verticalCenter", 0);
image.setStyle("horizontalCenter", 0);
root.slideshow.addChild(canvas);