我想为 Flex 开发一个网络图应用程序 - 想象一下将节点放置在 Canvas 上并通过链接将它们连接起来。节点应该具有可编辑的文本和其他 UI 组件。
我试图找到从头开始创建全新 UI 组件的示例,但我能找到的只是扩展现有组件的微不足道的示例:例如,扩展 Button 的 RedButton,或具有状态的 ComboBox从中选择。
我的主要问题是,什么 ActionScript 方法定义了组件的绘制? Java 的paint() 方法的ActionScript 等价物是什么?
最佳答案
您想创建一个覆盖 updateDisplayList 方法的组件,并在其中进行绘图:
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
关于apache-flex - 弹性 : How to create an entirely new component?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/489024/