> the lack of definitive info on this topic is pretty amazing to me
 
Ben, what could be more definitive than the approach that the Flex SDK
team takes for its own components? You don't have to follow our lead,
but I still think it counts as best practice.
 
Flex framework SWCs, such as framework.swc and airframework.swc, contain
a defaults.css file, and this file references embeddable assets that are
also in the SWC. The "host of problems" you are referring to (and I
don't understand what they are) can't be any worse than those Flex
developers encounter simply by using the standard Flex SWCs.
 
- Gordon

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of ben.clinkinbeard
Sent: Wednesday, January 23, 2008 12:21 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Seriously, what is the 'right' way to do default
styles?



OK, the lack of definitive info on this topic is pretty amazing to me
so I would like to help get something out there once and for all. The
problem to which I am referring is how to define default yet
overridable styles for custom components, including times when those
styles require embedded assets. This has been discussed before, but
the threads seem to endorse differing methods and neither provides
much in the way of concrete examples.

http://tech.groups.yahoo.com/group/flexcoders/message/98546?threaded=1&p
=8
<http://tech.groups.yahoo.com/group/flexcoders/message/98546?threaded=1&;
p=8> 
http://tech.groups.yahoo.com/group/flexcoders/message/94547
<http://tech.groups.yahoo.com/group/flexcoders/message/94547> 

I will use my personal efforts as an example here because its fairly
complex and I think if we can define a solution for it then most other
scenarios will be covered in the process. I have a component,
MDIWindow. I want its style to point to other styles (as seen in Panel
with titleStyleName and various other places in the Flex framework)
with properties named focusStyleName and noFocusStyleName. Those
"second-level" styles will then embed assets and contain a
ClassReference directive. The end user should be able to define a
MDIWindow style in their CSS but should also be able to specify
styleName on an instance and have it point to alternate styles (all
MDIWindow instances should not have to be styled the same).

The classConstruct() static method + AS and defaultFactory()
(mentioned by Alex above as probably the best option) works well for
defining the MDIWindow type selector styles but falls short of
supporting the styleName path since its static and cannot reference
instance properties.

The CSS approach (recommended by Gordon above) has issues when it
comes to embedding assets in the resulting SWC (I think) unless you
use the defaults.css approach, but that comes with its own host of
problems (http://tech.groups.yahoo.com/group/flexcoders/message/99374
<http://tech.groups.yahoo.com/group/flexcoders/message/99374> ).

I (and many others I think) are simply looking for an approach that is
flexible, compatible with Flex 2.x and preferably has the "recommended
by Adobe" stamp. I figure at the very least maybe we can get two of
the SDK engineers to duke it out (Deepa, you're in charge of
photgraphing), and hopefully whoever can still use a keyboard
afterwards will post a wonderfully detailed diatribe on the "right"
way to do default styles.

Thanks!
Ben



 

Reply via email to