|
A UIComponent gets its styles by calling the
getStyle() method that it inherits from UIComponent, not the getStyle() method on
CSSStyleDeclaration. I'll try to explain the difference. The getStyle() method on
CSSStyleDeclaration simply looks at the styles set in that single
CSSStyleDeclaration object., which represents a single CSS type selector like Button { color: red } or a single CSS class selector like .red { color: red } By contrast, the getStyle() method on
UIComponent searches a whole chain of style-containing objects, stopping when
it finds the style defined somehwere. First it looks at the styles set on that
instance. Then it looks in the styles defined by the class selector. Then it
looks in the styles defined by the type selector for the component's class (or
if that doesn't exist, for the type selector of its superclass, etc.). Then, if
it is an inheriting style, the process continues with the component's parent
container, and its parent container, etc., up to the application object.
Finally, it looks in the global styles. This chain of style-containing objects is sometimes
called the "style prototype chain" because each object links to the
next one via the ECMAScript "prototype" property on every Object. (Actually,
there are two chains, whose starting points are the objects _inheritingStyles
and _nonInheritingStyles on UIComponent.) This means that a call like getStyle("color")
can be implemented as a single property lookup,
_inheritingStyles["color"], which will search the entire chain at C++
speed. in the player! Is that cool or what? The "prototype" property
is a legacy of ECMAScript-style "prototype-based inheritance", which
is otherwise barely used in ActionScript 3 because AS3 introduced class-based
inheritance. The objects in this style prototype chain
are not CSSStyleDeclaration instances, but rather style-containing objects
produced by the factory functions in those CSSStyleDeclaration instances. So... if you really want to change style
lookup, you could override UIComponent's public getStyle() method or
UIComponent's initProtoChain() method, which is undocumented and subject to
change, but lives in the mx_internal namespace. - Gordon From:
[email protected] [mailto:[EMAIL PROTECTED] On Behalf Of sergio_trejo_r Is there a way to extend the CSSStyleDeclaration class
in such a way -- 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
YAHOO! GROUPS LINKS
__,_._,___ |

