Figured it out - used complete() to call. Only one thing wierd. I'm
doing this on 5 images, and one image doesn't seem to load. My debug
shows complete() firing though, but the image width is marked as
6710886, which is pretty darn huge for an image. :)
On 10/23/05, Raymond Camden <[EMAIL PROTECTED]> wrote:
> I'm loading a large image into a canvas. When the image loads, I want
> to center the image inside the view port. Here is how I have the image
> defined:
>
> <mx:Canvas id="viewport" width="100%" height="100%"
> vScrollPolicy="off" hScrollPolicy="off">
> <mx:Image id="mapImage" source="{mapPath}"
> mouseDown="handleMouseDown()"
> mouseUpSomewhere="handleMouseUp()"
>
> mouseMoveSomewhere="handleMouseMove()" />
> </mx:Canvas>
>
> I've tried a code to center items like so:
>
> function center() {
> var viewPortWidth:Number = viewport.width;
> var viewPortHeight:Number = viewport.height;
> var thisWidth = this.mapImage.width;
> var thisHeight = this.mapImage.height;
>
> var newX = Math.round((viewPortWidth - thisWidth) /
> 2);
> var newY = Math.round((viewPortHeight - thisHeight) /
> 2);
>
> this.mapImage.x = -1 * newX;
> this.mapImage.y = -1 * newY;
>
> Echo.debug("new coord "+newX +","+ newY+" the width
> was "+thisWidth);
> }
>
> However, I noticed that width was 0, so I got unexpected results. Do I
> need to wait for the image to finish loading? If so - how/when would
> I run center?
>
> --
> =======================================================================
> Raymond Camden, Director of Development for Mindseye, Inc (www.mindseye.com)
>
> Member of Team Macromedia (http://www.macromedia.com/go/teammacromedia)
>
> Email : [EMAIL PROTECTED]
> Blog : ray.camdenfamily.com
> Yahoo IM : cfjedimaster
>
> "My ally is the Force, and a powerful ally it is." - Yoda
>
--
=======================================================================
Raymond Camden, Director of Development for Mindseye, Inc (www.mindseye.com)
Member of Team Macromedia (http://www.macromedia.com/go/teammacromedia)
Email : [EMAIL PROTECTED]
Blog : ray.camdenfamily.com
Yahoo IM : cfjedimaster
"My ally is the Force, and a powerful ally it is." - Yoda
------------------------ Yahoo! Groups Sponsor --------------------~-->
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~->
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/