canvas
absolute positioning in flex - simple example
Submitted by benl on Thu, 05/06/2010 - 15:16
<mx:Canvas
xmlns:mx="http://www.adobe.com/2006/mxml"
autoLayout="false"
height="50">
<mx:HBox backgroundColor="0x000000" width="50" height="50"/>
<mx:Label text="SOME TEXT" />
</mx:Canvas>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);