Flex:如何创建一个全新的组件? [英] Flex: How to create an entirely new component?
问题描述
我试图找到从头创建一个全新的UI组件的例子,但所有我已经能找到扩展现有组件的简单示例:例如,扩展Button的RedButton,或者可选择状态的ComboBox。
我的主要问题是< b>什么是ActionScript方法定义了组件的绘图?什么是Java的paint()方法的ActionScript等价物?解析方案
$ b
覆盖保护函数updateDisplayList 您需要创建一个覆盖updateDisplayList方法的组件, (unscaledWidth:Number,unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth,unscaledHeight);
//在组件graphics属性
graphics.clear()上找到了绘图API。
graphics.lineTo(0,unscaledWidth);
// etc
}
更多信息可以在这里找到: http://livedocs.adobe.com/flex/3/html /help.html?content=ascomponents_advanced_3.html
I'd like to develop a network graph application for Flex - imagine placing nodes on a Canvas and connecting them with links. The nodes should have editable text and other UI components.
I'm trying to find examples of creating an entirely new UI component from scratch, but all I've been able to find are trivial examples that extend existing components: a RedButton that extends Button, for example, or a ComboBox that has states to choose from.
My main question is, what ActionScript method defines the drawing of a component? What is the ActionScript equivalent of Java's paint() method?
You want to create a component that overrides the updateDisplayList method, and do your drawing in there:
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList( unscaledWidth, unscaledHeight );
// The drawing API is found on the components "graphics" property
graphics.clear();
graphics.lineTo( 0, unscaledWidth );
// etc
}
More information can be found here: http://livedocs.adobe.com/flex/3/html/help.html?content=ascomponents_advanced_3.html
这篇关于Flex:如何创建一个全新的组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!