Re: [flexcoders] set dataObject() and null properties
On 2/8/06, tobiaspatton <[EMAIL PROTECTED]> wrote: > override public function set dataObject > (value:Object):void > { > super.dataObject = value; > trace( value.image, image); > > if( image != null ) > { > image.source = value.image; > } > } [snip] > From the output we can see that the dataObject setter function is > being called once when the image parameter is a real value, but for > all subsequent calls, the image parameter is null. > > Why would this be? It's hard to set the source parameter of null. Child objects are created in the component's "createChildren" method, which is called only when the component is added to the display list - which, in the case of cell renderers, is after their "dataObject" property is set. Property setters should be coded to assume that child objects have not been created. This is what I'd do: function set dataObject(value) { super.dataObject = value; invalidateDisplayList(); } function updateDisplayList() { image.source = value.image; } It's also more efficient if you set the image's source in updateDisplayList. -- 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/
[flexcoders] set dataObject() and null properties
Hello; I'm trying to get some understanding of renderers for lists and data grids. I'm working with, and adapting, the sample code presented in the Flex 2 documentation. Here's what I have (catalog.xml is from the flexstore example): -- prototype.mxml - http://www.macromedia.com/2005/mxml"; xmlns:local="*"> - Thumbnail.mxml - http://www.macromedia.com/2005/mxml"; horizontalAlign="center" verticalGap="0" borderStyle="none" > -- debugger output -- [SWF] C:\Documents and Settings\tpatton\My Documents\Flex\Prototype1 \bin\Prototype1-debug.swf - 615,987 bytes after decompression assets/pic/Nokia_6010.gif Application_5._HorizontalList1:HorizontalList.ListBaseContentHolder_1 0.hiddenItem:VBox.image:Image assets/pic/Nokia_6010.gif null assets/pic/Nokia_3100_blue.gif null assets/pic/Nokia_3100_pink.gif null assets/pic/Nokia_3120.gif null assets/pic/Nokia_3220.gif null assets/pic/Nokia_3650.gif null assets/pic/Nokia_6820.gif null assets/pic/Nokia_6670.gif null assets/pic/Nokia_6620.gif null [Unload SWF] C:\Documents and Settings\tpatton\My Documents\Flex\Prototype1\bin\Prototype1-debug.swf >From the output we can see that the dataObject setter function is being called once when the image parameter is a real value, but for all subsequent calls, the image parameter is null. Why would this be? It's hard to set the source parameter of null. Thanks. Tobias. -- 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/