The UIComponent class is the base class for all Flex visual components. For detailed documentation, see UIComponent in the Adobe Flex Language Reference.
The following table lists only the most commonly used properties of components that extend the UIComponent class:
Property
Type
Description
doubleClickEnabled |
Boolean
|
Setting to true lets the component dispatch a doubleClickEvent when a user presses and releases the mouse button twice in rapid succession over the component.
|
enabled |
Boolean
|
Setting to true lets the component accept keyboard focus and mouse input. The default value is true.
If you set enabled to false for a container, Flex dims the color of the container and all of its children, and blocks user input to the container and to all its children.
|
height |
Number
|
The height of the component, in pixels.
In MXML tags, but not in ActionScript, you can set this property as a percentage of available space by specifying a value such as 70%; in ActionScript, you must use the percentHeight property.
The property always returns a number of pixels. In ActionScript, you use the perCent
|
id |
String
|
Specifies the component identifier. This value identifies the specific instance of the object and should not contain any white space or special characters. Each component in a Flex document must have a unique id value. For example, if you have two custom components, each component can include one, and only one Button control with the id "okButton".
|
percentHeight |
Number
|
The height of the component as a percentage of its parent container, or for <mx:Application> tags, the full height of the browser. Returns NaN if a percent-based width has never been set or if a width property was set after the percentWidth was set.
|
percentWidth |
Number
|
The width of the component as a percentage of its parent container, or for <mx:Application> tags, the full span of the browser. Returns NaN if a percent-based width has never been set or if a width property was set after the percentWidth was set.
|
styleName |
String
|
Specifies the style class selector to apply to the component.
|
toolTip |
String
|
Specifies the text string displayed when the mouse pointer hovers over that component.
|
visible |
Boolean
|
Specifies whether the container is visible or invisible. The default value is true, which specifies that the container is visible.
|
width |
Number
|
The width of the component, in pixels.
In MXML tags, but not in ActionScript, you can set this property as a percentage of available space by specifying a value such as 70%; in ActionScript, you must use the percentWidth property.
The property always returns a number of pixels.
|
x |
Number
|
The component's x position within its parent container. Setting this property directly has an effect only if the parent container uses absolute positioning.
|
y |
Number
|
The component's y position within its parent container. Setting this property directly has an effect only if the parent container uses absolute positioning.
|
Every Flex component has an MXML API and an ActionScript API. A component's MXML tag attributes are equivalent to its ActionScript properties, styles, behaviors, and events. You can use both MXML and ActionScript when working with components.
- Set the value of a component property, event, style, or behavior declaratively in an MXML tag, or at run time in ActionScript code.
- Call a component's methods at run time in ActionScript code. The methods of an ActionScript class are not exposed in the MXML API.
The following example creates a Button control in MXML. When the user clicks the Button control, it updates the text of a TextArea control by using an ActionScript function.
<?xml version="1.0"?>
<!-- components/ButtonApp.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
public function handleClick():void {
text1.text="Thanks for the click!";
}
]]>
</mx:Script>
<mx:Button id="button1"
label="Click here!"
width="100"
fontSize="12"
click="handleClick();"/>
<mx:TextArea id="text1"/>
</mx:Application>
This example has the following elements:
- The id property is inherited by the Button control from the UIComponent class. You use it to specify an identifier for the component. This property is optional, but you must specify it if you want to access the component in ActionScript.
- The label property is defined by the Button control. It specifies the text that appears in the button.
- The width property is inherited from the UIComponent class. It optionally specifies the width of the button, in pixels.
- The Button control dispatches a click event when a user presses and releases the main mouse button. The MXML click attribute specifies the ActionScript code to execute in response to the event.
- The fontSize style is inherited from the UIComponent class. It specifies the font size of the label text, in pixels.
Note: The numeric values specified for font size in Flex are actual character sizes in the chosen units. These values are not equivalent to the relative font size specified in HTML by using the <font> tag.
The click event attribute can also take ActionScript code directly as its value, without your having to specify it in a function. Therefore, you can rewrite this example as the following code shows:
<?xml version="1.0"?>
<!-- components/ButtonAppAS.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Button id="button1"
label="Click here!"
width="100"
fontSize="12"
click="text1.text='Thanks for the click!';"/>
<mx:TextArea id="text1"/>
</mx:Application>
Both of these examples result in the following image, after the button is clicked:
Note: Although you can specify multiple lines of ActionScript code (separated by semicolons) as the value of the click event attribute, for readability you should limit the click event to only one or two lines of code.
Flex uses MXML property attributes to initialize your components. However, you might want to use some logic to determine initial values at run time. For example, you might want to initialize a component with the current date or time. Flex must calculate this type of information when the application executes.
Every component dispatches several events during its life cycle. In particular, all components dispatch the following events that let you specify ActionScript to initialize a component:
preInitialize
Dispatched when a component has been created in a rough state, and no children have been created.
initialize
Dispatched when a component and all its children have been created, but before the component size has been determined.
creationComplete
Dispatched when the component has been laid out and the component is visible (if appropriate).
Note: For more information on how components are created, see
You can use the initialize event to configure most component characteristics; in particular, use it to configure any value that affects the component's size. Use the creationComplete event if your initialization code must get information about the component layout.
The following example configures Flex to call the initDate() function when it initializes the Label control. When Flex finishes initializing the Label control, and before the application appears, Flex calls the initDate() function.
<?xml version="1.0"?>
<!-- components/LabelInit.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
private function initDate():void {
label1.text += new Date();
}
]]>
</mx:Script>
<mx:Box borderStyle="solid">
<mx:Label id="label1"
text="Today's Date: "
initialize="initDate();"/>
</mx:Box>
</mx:Application>
This example produces the following image:
You can also express the previous example without a function call by adding the ActionScript code in the component's definition. The following example does the same thing, but without an explicit function call:
<?xml version="1.0"?>
<!-- components/LabelInitAS.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Box borderStyle="solid">
<mx:Label id="label1"
text="Today's Date:"
initialize="label1.text += new Date();"/>
</mx:Box>
</mx:Application>
As with other calls that are embedded within component definitions, you can add multiple ActionScript statements to the initialize MXML attribute by separating each function or method call with a semicolon. The following example calls the initDate() function and writes a message in the flexlog.txt file when the label1 component is instantiated:
<?xml version="1.0"?>
<!-- components/LabelInitASAndEvent.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
private function initDate():void {
label1.text += new Date();
}
]]>
</mx:Script>
<mx:Box borderStyle="solid">
<mx:Label id="label1"
text="Today's Date:"
initialize="initDate(); trace('The label is initialized!');"/>
</mx:Box>
</mx:Application>
The following table summarizes the MXML and ActionScript component APIs that you use to configure components:
MXML example
ActionScript example
Read-write property
|
<mx:Tile id="tile1"
label="My Tile"
visible="true"/> |
tile1.label="My Tile"; tile1.visible=true;
|
Read-only property
|
You cannot use a read-only property as an attribute in MXML.
|
To get the value of a read-only property:
var theClass:String=mp1.className;
|
Method
|
Methods are not available in MXML.
|
myList.sortItemsBy("data", "DESC"); |
Event
|
<mx:Accordion id="myAcc"
change="changeHandler
(event);"/>
You must also define a changeHandler() function as shown in the ActionScript example.
|
private function
changeHandler(event:MouseEvent):void { ... } myButton.addEventListener("click", changeHandler);
|
Style
|
<mx:Tile id="tile1"
paddingTop="12"
paddingBottom="12"/> |
To set the style:
tile1.setStyle("paddingTop", 12); tile1.setStyle("paddingBottom", 12);
To get the style:
var currentPaddingTop:Number = tile1.getStyle("paddingTop");.
|
Behavior
|
<mx:Tile id="tile1"
showEffect="{AWipeEffect}"/> |
To set the behavior:
myButton.setStyle('showEffect',
AWipeEffect);
To get the behavior:
var currentShowEffect:String = tile1.getStyle("showEffect");
|
相关推荐
UIComponent.unitypackage
UIComponent
This is a Flex UIComponent that can be used 谋n a FLEX 3 mxml application as component written in action script 3.0, provides you to create items that cab be filled from an XML or Query ResultSet or ...
- Extends the Adobe’s™ UIComponent class (no need to relearn a new system) - Display and embed URLs in your application* - Display HTML pages in your application* - Display ...
UICOMPONENT 旨在直接替代 Matlab 的内置 UICONTROL 和 JAVACOMPONENT 函数。 它接受 UICONTROL 接受的所有参数和样式,以及任何其他可显示的 Java (Swing/AWT) 组件类。 保留了 UICONTROL 的调用约定和语法以实现...
MatlabGUI使用java组件无所不能-uicomponent.m 是不是曾经想做出漂亮的GUI 界面? 是不是曾经想在 Matlab GUI里面显示网页? 看看这个界面: matlab_java.png 所以,...
CustomComponent 自定义组件(空视图、标题、表单输入项、设置项、菜单项、按钮、文字) 继承于ConstraintLayout EmptyView 空数据视图-(图标加文字描述) 属性表格 name format description empty_title ...
BlurryLoading-UiComponent
flex开发自定义控件
可作为component 使用 (此图片来源于网络,如有侵权,请联系删除! ) 直接上代码 (此图片来源于网络,如有侵权,请...viewclass="uiComponent uiComponent_mask uiComponent_mask_{{uiComponent.mask.show &&'active'}}
与 Tiles 相比,Facelets 的优势在于它预先集成了 JSF UIComponent,并且不需要 Facelets 配置文件,而 Tiles 需要 Tiles 配置文件。 在 Facelets 中可以添加 JSF 验证器和转换器。Facelets 全面支持表达式语言 (EL...
在Page顶部下滑一个提示条 , 代码见 /mixins/UIComponent.js ,其中的self 可以认为是微信小程序的Page对象 (此图片来源于网络,如有侵权,请联系删除! ) 效果: 默认2秒展示,上移动画隐藏 /** * 展示顶部 tip , 多...
React过度 一个使用Dart构建静态类型的React UI组件的库。 该库还公开了OverReact Redux ,它具有。... 查看《 UiComponent2迁移指南》以了解UiComponent2的优势,可以运行的codemod脚本以及可能需要手动进行的其他
mkdir -p Customizing/global/plugins/Services/UIComponent/UserInterfaceHook cd Customizing/global/plugins/Services/UIComponent/UserInterfaceHook git clone ...
将呈现方法更改为以下方法(Row.java第67行)后,它可以按预期工作:public void render(UIComponent parent){UIComponent Composite = Components.includeCompositeComponent(parent,“ qcockpit”,Row....
mkdir -p Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/ cd Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/ git clone ...
import fl.core.UIComponent; var TF : TextFormat = new TextFormat(); TF.size = 16; TF.color = 0x0000ff; key.setStyle("textFormat",TF); ss.addEventListener(MouseEvent.CLICK,ft); function ft(en:Event) {...
在用 ActionScript 创建自定义组件时,必须重载 UIComponent 类的一些方法.实现基本的 组件结构,构造器,以及 createChildren(),commitProperties(), measure(), layoutChrome() 和 updateDisplayList()方法.