当前位置:首页 > 开发 > Web前端 > 前端 > 正文

flex style的继承顺序

发表于: 2012-10-10   作者:darrenzhu   来源:转载   浏览次数:
摘要: If you define a style in only one place in a document, Flex uses that definition to set a property’s value. However, an application can have several style sheets, local style definitions, external sty
If you define a style in only one place in a document, Flex uses that definition to set a property’s value. However, an application can have several style sheets, local style definitions, external style properties, and style properties set directly on component instances. In such a situation, Flex determines the value of a property by looking for its definition in all these places in a specific order.

Lower-level styles take precedence over higher-level or external styles. If you set a style on an instance, and then set the style globally, the global style does not override the local style, even if you set it after you set the local style.

Style inheritance order
The order in which Flex looks for styles is important to understand so that you know which style properties apply to which controls.

Flex looks for a style property that was set inline on the component instance. If no style was set on the instance using an inline style, Flex checks if a style was set using an instance’s setStyle() method. If it did not directly set the style on the instance, Flex examines the styleName property of the instance to see if a style declaration is assigned to it.

If you did not assign the styleName property to a style declaration, Flex looks for the property on type selector style declarations. If there are no type selector declarations, Flex checks the global selector. If all of these checks fail, the property is undefined, and Flex applies the default style.

In the early stages of checking for a style, Flex also examines the control’s parent container for style settings. If the style property is not defined and the property is inheritable, Flex looks for the property on the instance’s parent container. If the property isn’t defined on the parent container, Flex checks the parent’s parent, and so on. If the property is not inheritable, Flex ignores parent container style settings.

The order of precedence for style properties, from first to last, is as follows:

  • Inline
  • Class selector
  • Type selectors (most immediate class takes precedence when multiple selectors apply the same style property)
  • Ancestor class’s type selector
  • Parent chain (inheriting styles only)
  • Theme defaults.css file
  • global selector

If you later call the setStyle() method on a component instance, that method takes precedence over all style settings, including inline.

Style definitions in <fx:Style> tags, external style sheets, and the defaults.css style sheet follow an order of precedence. The same style definition in defaults.css is overridden by an external style sheet that is specified by an <fx:Style source="stylesheet"/> tag, which is overridden by a style definition within an <fx:Style> tag.

注意点,如果你用styleManager.loadStyleDeclarations("assets/dynamicStyle.swf",true)的方式动态加载样式,那么动态加载的样式在生命周期内将会覆盖上述定义的样式,当然如果某些样式并没有出现在动态加载的样式里面,当然是不会被覆盖的,可以多次动态加载样式。

flex style的继承顺序

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
加载顺序为 父类静态定义初始化 子类静态定义初始化 父类定义初始化 父类构造方法 子类定义初始化
组件与控件的区别: 组件:component指任何可复用的、可以与其他对象交互的对象,如Flex中的validato
  很多时候,在创建一个Flex应用程序,不知道什么时候执行哪儿个启动事件。它们被执行的顺序是怎
  很多时候,在创建一个Flex应用程序,不知道什么时候执行哪儿个启动事件。它们被执行的顺序是怎
  很多时候,在创建一个Flex应用程序,不知道什么时候执行哪儿个启动事件。它们被执行的顺序是怎
先看代码,写出结果 class A { public A() { PrintFields(); } public virtual void PrintFields(){
由架构中基类的设计想到的...... 现在,有三个类,类的定义如下 #include <iostream> using n
Flex中通过继承可以为新组件增加新的功能,如通过注入方法,改变背景色,改变位置和高度等。这里主要
一、本文目的与说明 1. 本文目的:理清在各种继承时,构造函数、复制构造函数、赋值操作符、析构函
class Base{ private String name = "base"; Base(){ tellName(); printName(name); } public void
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号