--- In flexcoders@yahoogroups.com, "droponrcll" <[EMAIL PROTECTED]> 
wrote:
>
> --- In flexcoders@yahoogroups.com, "Alex Harui" <aharui@> wrote:
> >
> > I suggest your renderer look something like this.  You'll see use 
of
> > dataChange and how to center the image.  I don't have a proxy 
> example,
> > but that's a good topic for a blog article someday...
> >  
> > Can you post two image swfs that don't center correctly?  I want 
to 
> make
> > sure those swfs are aligned to topleft otherwise this centering 
code
> > won't work for you.
> >  
> > <mx:Canvas dataChange="mediaObject= data as MediaElement">
> > <mx:Script>
> >     private var _mediaObject:MediaElement;
> >  
> >     [Bindable("mediaObjectChanged")]
> >     public function get mediaObject():MediaElement
> >     {
> >         return _mediaObject;
> >     }
> >  
> >     public function set mediaObject(value:MediaElement):void
> >     {
> >         _mediaObject = value;
> >         dispatchEvent(new Event("mediaObjectChanged");
> >     }
> >  
> >     private function centerImage():void
> >     {
> >         img.x = (width - img.measuredWidth) / 2;
> >         img.y = ???
> >     }
> > </mx:Script>
> > <mx:Image id="img" source="{mediaObject.imgSrc}"
> > complete="centerImage()" />
> > ...
> 
> I tried this, and it put the image pretty far away from the upper 
> left corner.  I'm guessing that this is because x and y are 
actually 
> the top left corner and not the center, though the docs are unclear 
> on this.  However, even when I corrected it to this:
> 
> private function centerMe(thing:SWFLoader):void{
>     thing.x = (width - thing.measuredWidth) / 2 - 
> (thing.measuredWidth/2);
>     thing.y = (height - thing.measuredHeight) / 2 - 
> (thing.measuredHeight/2);
> }
> 
> it still puts the image far enough away from the corner to require 
> scroll bars.  Any ideas?

OK, it looks like at least part of the problem is that the image is 
no longer scaling down properly now it is in a canvas instead of a 
vbox and it is no longer asking to be 100%.  Not sure which is the 
issue.  So, my speculation is that neither math could possibly 
position the image/swfloader properly, since both the image and the 
swf are now larger than the canvas.  Grrr.

Reply via email to