如何在 Flex MXML 文件中绘制圆?
在我的 MXML 文件中,我有一个带有三个 vbox 的选项卡导航器。
<mx:TabNavigator width="624" height="100%">
<mx:VBox label="Currents Quote"
width="100%">
</mx:VBox>
<mx:VBox label="Quote Comparison"
width="100%">
</mx:VBox>
<mx:VBox label="Reports"
width="100%">
</mx:VBox>
</mx:TabNavigator>
在 VBox“当前报价”内,我想绘制一个圆圈。我怎样才能实现它?
In my MXML file, I have a tab navigator with three vboxes.
<mx:TabNavigator width="624" height="100%">
<mx:VBox label="Currents Quote"
width="100%">
</mx:VBox>
<mx:VBox label="Quote Comparison"
width="100%">
</mx:VBox>
<mx:VBox label="Reports"
width="100%">
</mx:VBox>
</mx:TabNavigator>
Inside the VBox "Current Quote", I want a circle to be drawn. How can I achieve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
没有定义 MXML 圆,因此您必须自己创建一个圆控件,然后可以将其包含在 MXML 中。
然后在您的 MXML 中,如果您声明一个命名空间以在包含控件的顶部引用它,则可以使用自定义控件...
上面的代码已输入到 StackOverflow 编辑器中,因此请检查它是否有效!
Web 上有很多关于扩展 UIComponent 和 Sprite 的帮助。 Adobe 文档非常全面。
编辑:
将您的控件作为命名空间包含在封闭控件或应用程序
HTH中
There's no MXML circle defined, so you have to create a circle control yourself and you can then include it in your MXML.
then in your MXML you can use your custom control if you declare a namespace to refer to it at the top of your containing control...
Code above was typed into the StackOverflow editor, so check it works!
There's a lot of help on the web for extending UIComponent and Sprite. The Adobe docs are pretty comprehensive.
EDIT:
Include your controls as a namespace in the enclosing control or application
HTH
还可以有一个选项来创建一个圆,Eclipse
Create Box 具有背景颜色(如果您想用任何颜色填充它)和特定的宽度和高度,并提供恰好一半宽度的角半径
示例:
There can be one more option to create a circle, eclipse
Create Box with background color (if you want to fill it with any color) and with specific width and height and provide corner radius with exactly half of width
example :
所以在 Flex 中这是一种可能性:
这应该可行:)
So in Flex this is a possibility:
That should work :)
修饰拖放等...
是的,几乎一切皆有可能。如果您不想使用饼图(我建议您查看它,因为它可能会使许多绘图代码变得非常简单),那么您需要修饰上面的 MyCircle 类以捕获 mouseDown 事件并启用从它使用 DragSource 对象。
您需要将这些函数(以及您最终支持拖/放的任何其他函数)设置为该对象上的事件侦听器。您可以在对象的构造函数中执行此操作,只需确保正在侦听正确的事件即可。
您需要进行一些挖掘,adobe 文档是你的朋友,但这一切都是完全可能的。当您向 MyCircle 添加更多内容时,您将通过将其分解为单独的控件而获得更大的好处。
Embellishing for drag and drop etc...
Yes, pretty much anything is possible. If you don't want to use a pie chart (which I recommend you look at because it might make a lot of the drawing code very simple) then you need to embellish the MyCircle class above to trap the mouseDown event and to enable dragging from it using a DragSource object.
You'll need to set these functions (and whichever else you wind up supporting for drag/drop) as event listeners on this object. You can do that in the object's constructor, you just have to make sure you are listening for the right event.
You have some digging to do, and the adobe docs are your friend, but it is all perfectly possible. As you add more to MyCircle you will get greater benefit from having it factored out into a separate control.
尝试以下代码:
Try the following code:
看看Degrafa。
Take a look at Degrafa.