--- In flexcoders@yahoogroups.com, "Alex Harui" <[EMAIL PROTECTED]> 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()" /> > ... >
Let me see if I understand what is going on here... The dataChange event will only fire if the component is being used as an itemrenderer, otherwise, the mediaObject will be set in the usual way...? We're dispatching a mediaObjectChanged event here, and I'm not sure why. What is listening for it? Or is it just good practice in case something wants to listen for it? The last question I have is about repositioning the image. My understanding is that the problem is actually the position of the image within the 100% image control. So since the control is 100%, I'm not sure how it _could_ be repositioned. Or, are you saying not to set the image control to 100%? Thanks! Amy