I see, if mediaObject you want to be your public interface to when you use it as a component instead of a renderer, then I would set up my bindings based on mediaObject instead of data. I'd probably just use a dataChange="mediaObject = data as MediaElement" in the top level instead of overriding the getter/setter.
In a Canvas there are no layout rules so you can place things on top of each other and turn one or the other off and on with visibility. That's what I would do and I would also calculate the centering solution then as well. With the advent of Actionscript 3 and the goal of maximized performance, the Flash Player did not allow interoperability between FlashPlayer9/AS3 SWFs and the ActionScript in older SWFs. You can use localConnection, but that's about it. For those of you trying to integrate older swf content, it has become much harder to do. You can use a proxy AS2 swf to communicate to your older content. That way you only have to tweak the one proxy swf instead of rebuild all of your older content. ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of droponrcll Sent: Monday, October 01, 2007 11:48 AM To: [email protected] Subject: [flexcoders] Re: MultiPurpose ItemRenderer --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "Alex Harui" <[EMAIL PROTECTED]> wrote: > > This renderer is based on VBox which is a container and is a bit > "heavy". I'm guessing that since you are showing movies that there > aren't too many of them, but if there were, you might eventually run > into performance issues. Lean-and-mean renderers are almost always > written in Actionscript. On my blog (blogs.adobe.com/aharui) I have > some examples. > > > > This renderer also uses states w/o transitions just to switch between > two views. Renderers get recycled as you scroll and the state switching > could be expensive since add/remove is slower than changing the visible > flag. > > > > Because you used a container and are using databinding to fill out the > fields, you probably don't need to override the data setter at all > because commitProperties is probably not needed (in fact, you didn't > implement and override). You also probably do not have to implement a > mapping to your value object. You'll save a few microseconds here and > there by doing so, but may not be worth the effort. > > > > Thus, in its most reduced form, this renderer could look more like this > (you might need some code for positioning and sizing): > > > > <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> > <http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> > " width="100" > height="120" > horizontalScrollPolicy="off" verticalScrollPolicy="off" > borderStyle="solid" > > <mx:Script> > <![CDATA[ > private function swfLoadHandler(e:Event):void{ > var swfContent:MoveClip = e.target.content as MovieClip; > swfContent.stop(); > }]]> > </mx:Script> > <mx:Image id="thumbImage" maintainAspectRatio="true" > source="{'images/'+ data.img}" scaleContent="true" height="95%" > width="95%" visible="{data.img.length > 0}" x="?" y="?" /> > </mx:VBox> > <mx:Label id="theCaption" width="100%" text="{data.caption}" > textAlign="center"/> > <mx:SWFLoader id="movie" > source="{'movies/'+data.swf}" maintainAspectRatio="true" width="95%" > height="95%" scaleContent="true" visible="{data.swf.length > 0}" /> > </mx:Canvas> I'm using a mapping to my MediaElement object because that object is contained in the source ArrayCollection and is also used to drive the "large" image viewer. The stop action doesn't actually work on Flash 6 files, which these have to be because they also need to run in Authorware, which hasn't had an upgrade to its Flash Xtra in about 5 years and never will now. It doesn't seem that you can actually get older Flash movies to stop from Flex without adding functionality and recompiling. I have to say that it seems that silly things like effects have been made easy in Flex, yet serious things, like controlling older swfs easily, have been made seriously difficult. You also forget that part of the goal is to be able to use the component _not_ as an ItemRenderer, or as an ItemRenderer where it is being called from a Repeater component. So while you can just look at data directly, what then happens when you go to use it not as an itemrenderer? My understanding is if you set a component's visible property to false, it will still take up space on the screen as if it were visible, so I'm a bit unsure of what you're doing here. -Amy

