Flex:如何创建一个全新的组件? [英] Flex: How to create an entirely new component?

查看:24
本文介绍了Flex:如何创建一个全新的组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为 Flex 开发一个网络图应用程序 - 想象一下将节点放置在 Canvas 上并通过链接将它们连接起来.节点应具有可编辑的文本和其他 UI 组件.

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.

我正在尝试寻找从头开始创建全新 UI 组件的示例,但我能找到的只是扩展现有组件的微不足道的示例:例如,一个扩展 Button 的 RedButton,或一个 ComboBox有状态可供选择.

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.

我的主要问题是,什么 ActionScript 方法定义了组件的绘制?Java 的paint() 方法的ActionScript 等价物是什么?

My main question is, what ActionScript method defines the drawing of a component? What is the ActionScript equivalent of Java's paint() method?

推荐答案

您想创建一个覆盖 updateDisplayList 方法的组件,并在其中进行绘图:

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
}

可在此处找到更多信息:http:///livedocs.adobe.com/flex/3/html/help.html?content=ascomponents_advanced_3.html

More information can be found here: http://livedocs.adobe.com/flex/3/html/help.html?content=ascomponents_advanced_3.html

这篇关于Flex:如何创建一个全新的组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆