Comments on: Separating Layout from Style and Functionality https://joshblog.net/2006/08/12/separating-layout-from-style-and-functionality/ Archive of older blog posts written by Josh Tynjala about Flash, Flex, and ActionScript Wed, 26 Jun 2013 02:52:46 +0000 hourly 1 https://wordpress.org/?v=4.9.9 By: Erik Westra https://joshblog.net/2006/08/12/separating-layout-from-style-and-functionality/#comment-272 Wed, 11 Oct 2006 06:22:32 +0000 http://www.zeuslabs.us/archives/87/separating-layout-from-style-and-functionality/#comment-272 As for the extending thingies, we do it the other way around.

We create an mxml file and call it nameVisual, then we extend it with an actionscript class:

class name extends nameVisual
{
};

This way, inside the actionscript class, you have code hinting on what you defined in the mxml file.

Greetz Erik

]]>
By: Neil https://joshblog.net/2006/08/12/separating-layout-from-style-and-functionality/#comment-271 Mon, 28 Aug 2006 16:25:31 +0000 http://www.zeuslabs.us/archives/87/separating-layout-from-style-and-functionality/#comment-271 Great, thanks Josh.

]]>
By: Josh Tynjala https://joshblog.net/2006/08/12/separating-layout-from-style-and-functionality/#comment-270 Fri, 25 Aug 2006 15:20:44 +0000 http://www.zeuslabs.us/archives/87/separating-layout-from-style-and-functionality/#comment-270 Steven Webster from Adobe Consulting has some good suggestions for when you should (or shouldn’t) start using Cairngorm. I personally have not used either architecture in any of my projects yet, and I suggest taking Steven’s advice to make sure that you know Flex well before starting with other frameworks to go on top of it.

]]>
By: nwebb https://joshblog.net/2006/08/12/separating-layout-from-style-and-functionality/#comment-269 Fri, 25 Aug 2006 12:29:41 +0000 http://www.zeuslabs.us/archives/87/separating-layout-from-style-and-functionality/#comment-269 Really glad I found this post as I’m just about to embark on my first Flex project and I have been musing over how best to separate script from my .mxml files.
Stas, great example. That feels very intuitive to me.

I’ve not used an architectural framework before (not sure how beneficial it would be for me to use Cairngorm or Arp until I’ve actually got a little more Flex2 experience under my belt? I’d be really interested in your opinions on this, as I’m a little worried it could be counter productive for me at this stage, even though, given the size of my first task, using a framework would ideally be the way to go).

The first project my employer has tasked me with is going to be quite large, so I’ve been knowingly over-architecting all my test files to get a feel for building something bigger. Any tips I can glean from those with more experience will be a bonus 🙂

]]>
By: paul https://joshblog.net/2006/08/12/separating-layout-from-style-and-functionality/#comment-268 Wed, 16 Aug 2006 04:48:04 +0000 http://www.zeuslabs.us/archives/87/separating-layout-from-style-and-functionality/#comment-268 funny… I just refactored my classes to use Base. I like it better as well. It’s more explicit.

]]>
By: Aral Balkan https://joshblog.net/2006/08/12/separating-layout-from-style-and-functionality/#comment-267 Tue, 15 Aug 2006 20:12:56 +0000 http://www.zeuslabs.us/archives/87/separating-layout-from-style-and-functionality/#comment-267 Hey guys, also check out the Pizza Service Flex 2 sample application in Arp. Arp uses code behind for Flash, Flex 1.5 and Flex 2 apps.

Make sure you checkout the latest from SVN (the release version is way too old and doesn’t contain the Flex stuff.)

http://svn1.cvsdude.com/osflash/arp/

Hope you enjoy the Quick Start 🙂

]]>
By: Josh Tynjala https://joshblog.net/2006/08/12/separating-layout-from-style-and-functionality/#comment-266 Tue, 15 Aug 2006 18:18:25 +0000 http://www.zeuslabs.us/archives/87/separating-layout-from-style-and-functionality/#comment-266 Aral Balkan has written a Flex Quick Start about “code behind” component development (using an AS class as your base for an MXML component). Like Paul’s “Behind” suffix and Stas’ “Base” suffix, Aral adds “Class” to the end of the component’s name. Personally, Base sounds the best to me so far, but I guess it’s up to your personal taste.

]]>
By: Stas https://joshblog.net/2006/08/12/separating-layout-from-style-and-functionality/#comment-265 Tue, 15 Aug 2006 16:04:33 +0000 http://www.zeuslabs.us/archives/87/separating-layout-from-style-and-functionality/#comment-265 Right Paul, the names shouldn’t be the same!

For example we call AS file “xxxBase” and MXML file just “xxx”.

And I agree it’s verbose, but I have been developing with this technique quite for a long time and it’s more like a habit now 🙂

]]>
By: paul https://joshblog.net/2006/08/12/separating-layout-from-style-and-functionality/#comment-264 Tue, 15 Aug 2006 07:09:16 +0000 http://www.zeuslabs.us/archives/87/separating-layout-from-style-and-functionality/#comment-264 Oh, also an awkward thing about the subclassing technique is the naming of your files. You can’t have the .as and .mxml the same name. There is a conflict with the generated class. End up with stuff like…

NewDocumentDialog.mxml
NewDocumentDialogBehind.as

Kinda nasty

]]>
By: paul https://joshblog.net/2006/08/12/separating-layout-from-style-and-functionality/#comment-263 Tue, 15 Aug 2006 07:03:49 +0000 http://www.zeuslabs.us/archives/87/separating-layout-from-style-and-functionality/#comment-263 I’ve been experimenting with all sorts of flavors trying to get the right feel. Ugh.. nothing feels clean yet. My latest stuff is using the ActionScript subclassing technique described above to emulate a code behind (a la .Net/XAML). So far it’s pretty clean but can be very verbose. And sometimes my brain chokes because I treat it like a code behind when it really isn’t.

The other thing I’ve tried to do is to componentize my functionality through command classes.

I like it but it doesn’t work in all cases.

In some cases where I only need a single method or very little code it is so tempting to just toss it into the markup but… ugh.. inline script just feels wrong. I actually haven’t even gone down the path of includes yet. I don’t know… having a dangling AS file just feels a little weird to me. I guess I’m a purist, to a fault.

Anyway, it’s great to see this topic discussed. It’s something that I feel like I’ve really been struggling with to find something that’s comfortable, clean, simple, and elegant.

]]>