Good poont. The example I gave is not exactly describing code-behind. I would use the <ui:AutoscrollList /> within another VBox (e.g), not as a top element.
Nevertheless, I do use code-behinds (using an Actionscript class as the top element of an MXML component) at times, but usually more as an abstract class where I expect there to be multiple subclasses, not as a code-behind for a single class. Cheers, -D Ralf Bokelberg wrote: > > From an OOP point of view, would you really create a subclass just to > divide the code into smaller pieces? > I guess no. Imho it's better practice to extract real classes/objects > from mxml files, if possible. > > Cheers, > Ralf. > > On 1/16/07, *Daniel Wabyick* <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > > I highly recommend it as well. > > As a simple example, I might want to enhance the List component to > autoscroll to the selected item upon selection. Simply create a class > 'AutoscrollList.as' that you can then use that class in your MXML > <ui:AutoscrollList />. (code included below) > > Like others, I don't use it when I add one or two UI centric > functions > to a UI class. > > Cheers, > -D > > package ui > { > import mx.controls.List; > > public class AutoscrollList extends ExtendedList > { > > override public function set selectedIndex( value:int ):void > { > super.selectedIndex = value; > scrollToSelected(); > } > > override public function set selectedItem( value:Object ):void > { > super.selectedItem = value; > > scrollToSelected(); > } > > override public function set dataProvider( value:Object ) : void > { > super.dataProvider = value; > scrollToSelected(); > } > > public function scrollToSelected() : void > { > // TRICKY: Delay the invocation to avoid redraw bugs > starting in 2.0.1 > if ( selectedIndex >= 0 ) > { > callLater( scrollToIndex, [ selectedIndex ] ); > } > //this.scrollToIndex( selectedIndex ); > } > > > } > } > > ben.clinkinbeard wrote: > > > > I am undecided as to whether or not I want to use the code behind > > method for my MXML files and figured I would see what others are > > doing. I am currently just using Script blocks at the top of my files > > to do event handling, initialization, etc but some of them are > getting > > pretty big. > > > > So what are others doing? No AS in your MXML files, no code behind, a > > mixture of the two? > > > > Thanks, > > Ben > > > > > > > > > -- > Ralf Bokelberg <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> > Flex & Flash Consultant based in Cologne/Germany > Phone +49 (0) 221 530 15 35 >

