Metadata Tags in Custom Components
You insert metadata tags into your MXML and ActionScript files to provide information to the Adobe® Flex® compiler.
Metadata tags do not get compiled into executable code, but provide information to control how portions of your code
get compiled.
Metadata statements are associated with a class declaration, an individual data field, or a method. They are bound to
the next line in the file. When you define a component property or method, add the metadata tag on the line before
the property or method declaration.
Metadata tags in ActionScript
In an ActionScript file, when you define component events or other aspects of a component that affect more than a
single property, you add the metadata tag outside the class definition so that the metadata is bound to the entire class,
MoreDetail
Style Metadata
name String (Required)
Specifies the name of the style.
type String
Specifies the data type of the value that you write to the style property. If the type is
not an ActionScript type such as Number or Date, use a qualified class name in the
form packageName.className.
arrayType String
If type is Array, arrayType specifies the data type of the Array elements. If the data
type is not an ActionScript type such as Number or Date, use a qualified class name in
the form packageName.className.
format String
Specifies the units of the property. For example, if you specify type as "Number" ,
you might specify format="Length" if the style defines a length measured in pixels.
Or, if you specify type="uint", you might set format="Color" if the style defines
an RGB color.
enumeration String
Specifies an enumerated list of possible values for the style property.
inherit String
Specifies whether the property is inheriting. Valid values are yes and no. This property refers to CSS inheritance, not object-oriented inheritance. All subclasses automatically use object-oriented inheritance to inherit the style property definitions of their superclasses.
Some style properties are inherited using CSS inheritance. If you set an inheritable style property on a parent container, its children inherit that style property. For example, if you define fontFamily as Times for a Panel container, all children of that container will also use Times for fontFamily, unless they override that property.
If you set a noninheritable style, such as textDecoration, on a parent container, only the parent container and not its children use that style. For more information on inheritable style properties, see About style inheritance.
states String
For skin properties, specifies that you can use the style to specify a stateful skin for multiple states of the component. For example, the definition of the Slider.thumbSkin style uses the following [Style] metadata tag:
[Style(name="thumbSkin", type="Class", inherit="no", states="disabled, down, over, up")]This line specifies that you can use the Slider.thumbSkin style to specify a stateful skin for the disabled, down, over, and up states of the Slider control. For more information, see Creating Halo Skins.
theme String
If the style is only valid for a specific theme, specifies the name of the theme. For example, some styles on Flex components are only valid if you are using the Spark or Halo theme. For more information, see About themes
Demo:
1· ColourComponent Class
ActionScript 3语言:
package
{
import mx.core.UIComponent;
/**
* This Class is use to Test the Style stuff
*
* name this one is to set the styleName , so later we can call
* getStyle(name) to get the styleValue
* type define the type for the style
* enumeration define the possible value for the style
* WARNING: the possible means the value can be one of in the enumeration ,or you can set new value
* which is not include in
* inherit set this style can be extends or not
*/
[Style(name="valueOne",type="String",enumeration="one,two,three,four",inherit="no")]
public class ColourComponent extends UIComponent
{
private var styleReceive:String;
public function ColourComponent(){ super(); }
override public function styleChanged(styleProp:String):void
{
trace("StyleProp :" + styleProp + " Changed");
styleReceive=getStyle("valueOne");
trace("styleReceive = " + styleReceive);
}
}
}
2· App.mxml
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/halo"
minWidth="640"
minHeight="480"
xmlns:local="*">
<fx:Script>
<![CDATA[
import mx.events.ListEvent;
protected function onChange(event:ListEvent):void
{
target.setStyle("valueOne", box.selectedLabel);
}
]]>
</fx:Script>
<fx:Style>
@namespace local "*";
@namespace mx "library://ns.adobe.com/flex/halo";
@namespace s "library://ns.adobe.com/flex/spark";
local|ColourComponent
{
value-one:one
}
</fx:Style>
<mx:VRule x="182"
y="0"
height="480"
width="10"/>
<s:Group x="187"
y="1"
width="454"
height="478">
<local:ColourComponent id="target">
</local:ColourComponent>
</s:Group>
<mx:ComboBox id="box"
x="9"
y="11"
dataProvider="{['one','two','three','four','five']}"
editable="true"
change="onChange(event)"/>
</s:Application>
More Info Plaease See 为自定义Flex Component定义Style
分享到:
相关推荐
8. **代码示例**:在提供的文档“Flex自定义Feature的style风格.doc”中,应该包含具体的代码片段,展示如何创建和应用自定义Style。 通过以上知识点,开发者可以根据需求创建出各种独特且富有表现力的地图展示效果...
将自定义的Context Menu与Flex组件关联,通常是通过设置组件的contextMenu属性实现。例如,为一个 mx:Canvas 组件添加右键菜单: ```actionscript canvas.contextMenu = contextMenu; ``` 四、动态创建和更新菜单 ...
使用Flex3 Style Explorer,开发者不仅可以探索Flex组件的默认样式,还可以学习如何通过改变特定样式属性来创建独特的视觉效果。这有助于提升应用程序的整体设计感,使之与品牌风格保持一致,或者根据用户需求进行...
Flex Style Explorer是一款强大的工具,专为Adobe Flex开发者设计,用于探索和实验Flex应用程序中的样式和皮肤。这个工具的两个主要版本——V2.0.1和V3.0,提供了不同的特性和改进,帮助开发者更好地理解和定制Flex...
Flex Style Explorer是一款专为Flash MX设计的插件,它提供了对Flex应用程序界面样式的深入探索和测试能力。在深入解析这个工具之前,我们先要理解Flex及其与Flash MX的关系。 Flex是Adobe公司开发的一种开源框架,...
在本文中,我们将深入探讨`Flex`布局以及如何在前端开发中创建自定义组件,特别是针对`Flex`下的下拉组件。`Flex`布局是一种强大的CSS(层叠样式表)布局模式,允许开发者轻松地创建响应式和动态的用户界面。这种...
它允许开发者直观地查看、修改和实验不同的Flex3组件样式属性,以便在实际应用中创建自定义的用户界面外观。这个工具对于理解Flex3的皮肤ning机制以及如何通过CSS样式表来定制UI元素至关重要。 Flex3是Adobe Flex...
Style Explorer V3.0 Beta 提供了一个平台,允许用户尝试不同的CSS属性,即时查看其在Flex组件上的效果。这对于快速原型设计和优化用户界面设计非常有用。 Flex 3的CSS和传统Web CSS有相似之处,但也有一些不同。...
在Flex 3中,CSS(Cascading Style Sheets)用于定义组件的外观和布局,包括颜色、字体、大小、间距等视觉属性。通过使用CSS,开发者可以实现与业务逻辑分离的界面设计,提高代码的可维护性和复用性。Flex 3 CSS ...
这个工具是Flex SDK的一部分,帮助用户理解并利用MXML和CSS(Cascading Style Sheets)来控制Flex应用程序的界面风格。 在Flex 3中,样式系统是一个强大的特性,它提供了丰富的自定义可能性,让应用程序界面能够...
在自定义组件中,需要确保组件支持样式应用,这通常通过`styleName`属性和`setStyle()`方法实现。 5. **注册组件**:为了让Flex编译器能够识别并使用你的组件,需要在项目或库的元数据中注册它。这通常通过`...
Flex3.Style.Explorer.V3.0 是一个专为FLEX开发者设计的强大工具,它使得创建和管理CSS(Cascading Style Sheets)样式变得更加直观和高效。在Flex开发中,CSS样式的应用对于构建用户界面的外观和交互性起着至关重要...
- `align-self`:允许单个Flex项目覆盖容器的`align-items`设定,自定义其在交叉轴上的对齐方式。 4. **响应式设计与Flex** 由于Flex布局的灵活性,它在响应式设计中扮演着重要角色。通过改变`flex-direction`、`...
在Flex开发中,自定义组件皮肤是提升应用界面美观度和用户体验的重要手段。本文将详细介绍如何在Flex中自定义按钮的皮肤,通过示例代码帮助理解这一过程。 首先,我们来看一个Flex应用的主文件Test.mxml。在这个...
"CSS style属性大全.rar"这个压缩包显然是一份关于CSS样式的全面教程资料,旨在帮助学习者掌握各种CSS属性的用法。下面将详细介绍一些关键的CSS style属性。 1. **颜色和文本样式** - `color`: 设置文本颜色,可以...
在本话题中,我们主要探讨的是如何在Flex中创建一个带有边框的Box容器以及自定义的CheckBox组件,这两种元素在Flex应用中是非常常见的。 首先,让我们来理解边框Box(BorderContainer)在Flex中的作用。...
而"kingnarestyle.swf"可能是一个预览或者包含自定义皮肤的SWF文件,它可能是Flex应用的一部分,展示了使用特定CSS样式后的界面效果。SWF文件是Adobe Flash的二进制格式,常用于展示动画、交互式内容或者Flex组件的...
标题“flex 嵌入文字样式”和描述“flex 嵌入外部文字样式,弥补flex内部字体不足的缺憾”提示我们关注如何在Flex容器中使用自定义或外部字体来增强文本表现力。 首先,让我们了解Flex布局的基本概念。Flex布局允许...
7. **自定义样式**:除了基本的Flex布局属性,用户可能还需要自定义颜色、边距、字体等其他样式。好的生成器会提供这些选项,以便用户生成更完整的CSS代码。 总之,Flex CSS生成器是现代前端开发的利器,它简化了...
此外,Flex还支持组件实例选择器(`[id=myButton]`)和自定义属性选择器(`[myAttribute=myValue]`),这些使得针对特定组件或属性应用样式变得更加灵活。 四、应用CSS的技巧与最佳实践 1. 分离样式:将CSS样式...