[flexcoders] Code behind- do you use it?
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
RE: [flexcoders] Code behind- do you use it?
The 32k problem in 1.5 forced me into using helper classes very early on. Still, though, I often develop in a script block, then later move the functionality to its own class. Typically, functions that need to updte the ui directly stay in the script block, and pure functions go in the class. Its not a hard rule, and I sometimes pass a reference to the needed scope into a helper class in order to manipulate the ui there. Tracy From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of ben.clinkinbeard Sent: Tuesday, January 16, 2007 1:27 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Code behind- do you use it? 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
Re: [flexcoders] Code behind- do you use it?
I've been thinking about asking the same question, all of the samples out there seem to embed the actionscript in MXML, however the code behind scenario seems more like a best practice approach. Personally, I use code behind everywhere except for procedural initialization code in my main.mxml. -Steve 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
RE: [flexcoders] Code behind- do you use it?
Yesterday I just refactored the project I am working on to use code behind. I had not planned on keeping script blocks in the MXML files, but being fairly new to Flex, when everything began working correctly I sort of forgot about it until some of the script blocks started getting larger and larger and then it kind of clicked that I had planned on moving the script out of the MXML. -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of ben.clinkinbeard Sent: Tuesday, January 16, 2007 1:27 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Code behind- do you use it? 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
Re: [flexcoders] Code behind- do you use it?
All, Thanks for this discussion! I hadn't heard of this before, so I googled it and found this article: http://www.adobe.com/devnet/flex/quickstart/building_components_using_code_behind/ I'm going to try this out and see how it works. Then maybe I'll be a beneficial poster to this discussion :) Mark On 1/16/07, Robert Chyko [EMAIL PROTECTED] wrote: Yesterday I just refactored the project I am working on to use code behind. I had not planned on keeping script blocks in the MXML files, but being fairly new to Flex, when everything began working correctly I sort of forgot about it until some of the script blocks started getting larger and larger and then it kind of clicked that I had planned on moving the script out of the MXML. -Original Message- *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *ben.clinkinbeard *Sent:* Tuesday, January 16, 2007 1:27 PM *To:* flexcoders@yahoogroups.com *Subject:* [flexcoders] Code behind- do you use it? 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
Re: [flexcoders] Code behind- do you use it?
So what are others doing? No AS in your MXML files, no code behind, a mixture of the two? I use it practically 100% of the time. If the mxml file only has a small amount of code and is unlikely to expand then its probably overkill but for anything with more than a couple of methods i use it. martin.
Re: [flexcoders] Code behind- do you use it?
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
Re: [flexcoders] Code behind- do you use it?
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] 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] Flex Flash Consultant based in Cologne/Germany Phone +49 (0) 221 530 15 35
Re: [flexcoders] Code behind- do you use it?
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
RE: [flexcoders] Code behind- do you use it?
I do everything in script blocks and write helper classes where needed. But I also breakdown the app as much as possible, so those script blocks and views are as small as possible. Dimitrios Gianninas RIA Developer Optimal Payments Inc. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of ben.clinkinbeard Sent: Tuesday, January 16, 2007 1:27 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Code behind- do you use it? 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 -- WARNING --- This electronic message and its attachments may contain confidential, proprietary or legally privileged information, which is solely for the use of the intended recipient. No privilege or other rights are waived by any unintended transmission or unauthorized retransmission of this message. If you are not the intended recipient of this message, or if you have received it in error, you should immediately stop reading this message and delete it and all attachments from your system. The reading, distribution, copying or other use of this message or its attachments by unintended recipients is unauthorized and may be unlawful. If you have received this e-mail in error, please notify the sender. AVIS IMPORTANT -- Ce message électronique et ses pièces jointes peuvent contenir des renseignements confidentiels, exclusifs ou légalement privilégiés destinés au seul usage du destinataire visé. L'expéditeur original ne renonce à aucun privilège ou à aucun autre droit si le présent message a été transmis involontairement ou s'il est retransmis sans son autorisation. Si vous n'êtes pas le destinataire visé du présent message ou si vous l'avez reçu par erreur, veuillez cesser immédiatement de le lire et le supprimer, ainsi que toutes ses pièces jointes, de votre système. La lecture, la distribution, la copie ou tout autre usage du présent message ou de ses pièces jointes par des personnes autres que le destinataire visé ne sont pas autorisés et pourraient être illégaux. Si vous avez reçu ce courrier électronique par erreur, veuillez en aviser l'expéditeur.