本文介绍了Flex:如何创建一个全新的组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想为Flex开发一个网络图形应用程序 - 设想将节点放置在Canvas上并将它们与链接连接起来。节点应该有可编辑的文本和其他UI组件。 我试图找到从头创建一个全新的UI组件的例子,但所有我已经能找到扩展现有组件的简单示例:例如,扩展Button的RedButton,或者可选择状态的ComboBox。 我的主要问题是什么是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:如何创建一个全新的组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-23 10:08