That would align the image container but not its contents.
the Image object is essentially a container for its content.
On 02/04/2007, at 11:20 AM, Doug McCune wrote:
What about using a VBox or a HBox instead of Canvas and using the
horizontalAlign="center" attribute? horizontalAlign isn't available
for canvas, but it is for the box containers.
Doug
On 01 Apr 2007 18:03:31 -0700, Bjorn
Schultheiss<[EMAIL PROTECTED]> wrote:
try this
override protected functionupdateDisplayList(unscaledWidth:Number,
unscaledHeight:Number): void
{
super.updateDisplayList( unscaledWidth, unscaledHeight );
if ( _image )
{
_image.width = unscaledWidth;
_image.height = unscaledHeight;
_image.scaleContent = true;
_image.maintainAspectRatio = true ;
_image.setStyle('verticalAlign', 'middle');
_image.setStyle('horizontalAlign' , 'center' );
}
}
this actually works :)
On 02/04/2007, at 3:30 AM, herklano wrote:
hi,
i'm kinda noob at coding in general, but i'm trying to work my way to
get a image that is loaded in a Canvas to center to it after it has
been loaded to it.
i'm trying this but it doesn't work:
<mx:Canvas
x="10" y="10" width="190" borderStyle= "none"
backgroundColor= "#d0d0d0" height="190">
<mx:Image id="SMCDadosImg"
complete="changeSMCDadosImg( event);" horizontalCenter="0"
verticalCenter= "0"/>
</mx:Canvas>
private function changeSMCDadosImg(event:Event) :void
{
var pW_SMCDadosImg:Number;
var pH_SMCDadosImg: Number;
pW_SMCDadosImg = event.target.width;
pH_SMCDadosImg = event.target.height;
trace("W = "+ pW_SMCDadosImg);
trace("H = "+ pH_SMCDadosImg) ;
if (pW_SMCDadosImg > pH_SMCDadosImg)
{
SMCDadosImg.height = 190;
SMCDadosImg. width = pW_SMCDadosImg/(190*pH_SMCDadosImg);
SMCDadosImg.x = 190/2 - SMCDadosImg.width/2;
}
else if (pW_SMCDadosImg < pH_SMCDadosImg)
{
SMCDadosImg.width = 190;
SMCDadosImg. height = pH_SMCDadosImg/(190*pW_SMCDadosImg);
SMCDadosImg.y = 190/2 - SMCDadosImg.height/2;
}
else if (pW_SMCDadosImg == pH_SMCDadosImg)
{
SMCDadosImg.height = 190;
SMCDadosImg. width = 190;
}
}