加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex中的CSS: (3)CSS会被编译器转换为什么样的AS代码--派生的

发布时间:2020-12-15 04:58:25 所属栏目:百科 来源:网络整理
导读:解说: id 选择器常常用于建立派生选择器。 test1.mxml ?xml version="1.0" encoding="utf-8"?s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="

解说:

id 选择器常常用于建立派生选择器。

test1.mxml

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
			   xmlns:s="library://ns.adobe.com/flex/spark"
			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
	<fx:Style>
		@namespace s "library://ns.adobe.com/flex/spark";
		@namespace mx "library://ns.adobe.com/flex/mx";
		#hg s|TextInput{
			color: #FF0000;
		}
	</fx:Style>
	<s:VGroup>
		<s:HGroup id="hg" verticalAlign="middle">
			<s:Label text="Text Input 1"/>
			<s:TextInput text="sample"/>
		</s:HGroup>
		<s:TextInput text="sample"/>
	</s:VGroup>
</s:Application>


执行结果:

编译器自动生成代码:

        var conditions:Array;
        var condition:CSSCondition;
        var selector:CSSSelector;
        selector = null;
        conditions = null;
        conditions = [];
        condition = new CSSCondition("id","hg");
        conditions.push(condition); 
        selector = new CSSSelector("*",conditions,selector);
        conditions = null;
        selector = new CSSSelector("spark.components.TextInput",selector);
        // *#hg spark.components.TextInput
        style = styleManager.getStyleDeclaration("*#hg spark.components.TextInput");
        if (!style)
        {
            style = new CSSStyleDeclaration(selector,styleManager);
        }

        if (style.factory == null)
        {
            style.factory = function():void
            {
                this.color = 0xff0000;
            };
        }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读