Jules:
Quoting from Steve and Alistair's Developing Rich Clients with
Macromedia Flex book (p.57):
"Developers should generally avoid inline ActionScript
where possible; instead, they should refactor code into external classes
imported at compile-time."
While
prototyping, and perhaps for small, exceptional cases, in-line AS is probably a
reasonable approach, however the "rule" expressed above certainly creates a more
easily managed configuration within a production
environment.
Hope
this helps.
Regards,
Damon
-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Julian Suggate
Sent: Wednesday, November 02, 2005 7:31 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] To code-behind or not to code-behind?Gidday everyone,Years back, I wrote php scripts with code embedded in the html and it led to maintenance hassles. Since then, I've migrated to Java and now .NET and what I liked about their models was the ability to separate the code into "code-behind", something done quite elegantly in ASP.NET. These eliminated a lot of the maintenance problems I'd encountered earlier with PHP.So when I saw macromedia's examples of mxml with <mx:Script>...</mx:Script> blocks embedded directly into the mxml, I immediately searched for a way to avoid this. I found that i could add a source=".." attribute to the mx:Script element and the AS code would be included by the compiler from an external file at compile time. The IDE was even smart enough that any elements I'd defined with id attributes in the mxml showed up with intellisense in the included AS file (I am using Flex Builder 2, not sure if FB1.5 had that feature or not).But now I'm having second thoughts. It kinda feels like going against the grain. I don't want to carry old biases into a new paradigm unnecessarily. I read an article by Aral Balkan (of ARP fame) endorsing the code-behind approach quite strongly, but by the same token, all sample apps from the Cairngorm team freely mix mxml and AS code, as do examples from macromedia themselves.I note though, that the Cairngorm framework itself is all pure AS; it is only the sample apps that use inline actionscript.I can't seem to find a best practice anywhere, because for every framework/example/article I find that seems to hint at one way of doing things, I find another one that suggests the opposite! Has anyone else with more Flex experience than me answered this question, particularly in terms of which approach is easier to maintain?At this stage, any hints would be appreciated!TIA,Jules
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
Web site design development Computer software development Software design and development Macromedia flex
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.