是否有一个 Flex 组件可以剪辑在其边界之外绘制的任何图形?
我使用 graphics
类来对象在 BorderContainer 上绘制。有些绘图脱离了组件边界,但它们仍然绘制在屏幕上。有什么办法可以裁剪图形绘制的区域吗?
无论如何,推荐使用的组件是什么?我需要可以在 Flex 中使用的最简单的东西,并且还能够添加标签。
I'm using the graphics
class to object to draw on BorderContainer. Some of the drawings fall off the components borders, but they are still drawn on screen. Is there any way to clip the area drawn with graphics?
What's the recommend component to draw on, anyway? I need the simplest thing that can I can draw on in Flex and have the ability to add Labels to as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您要对 BorderContainer 进行换肤,只需在 Skin 上将 ClipAndEnableScrolling 设置为 true 即可。
如前所述,Group 或 SpriteVisualElement 易于利用。另外,如果需要的话,戴个口罩也是不错的。
您需要 Spark 标签还是只需要 TextFields?
也许创建一个可以应用皮肤类的spark.components.SkinnableContainer会是理想的选择吗?
实现 - 可换肤容器设置您在其上绘图的皮肤,并将 MXML 内容放置在其中:
示例容器
示例皮肤 - 在此处进行绘图
If you're skinning the BorderContainer, just set clipAndEnableScrolling to true on the Skin.
As mentioned, Group or SpriteVisualElement are lean to draw on. Also, a mask would be good if needed.
Do you need Spark Labels or just TextFields?
Maybe creating a spark.components.SkinnableContainer you can apply skin classes would be ideal?
Implementation - Skinnable Container sets the skin you draw on, and you place your MXML content inside:
Example Container
Example Skin - Do your drawing here
将绘图限制在给定区域时,请尝试使用 mask 属性(
DisplayObject
的每个子类都有它)。它的创建正是为了满足您的要求。在您可以利用的最简单的IVisualElementContainer上,尝试使用组。
On restricting drawing to a given region, try using the mask property (every subclass of
DisplayObject
has it). It was created to do exactly what you're asking about.On the simplest IVisualElementContainer you can draw on, try using a Group.
您可以做的是使用 SpriteVisualElement 进行绘制,将其宽度和高度设置为 100% 并将其放入 Group 中。然后启用 Group 的属性 clipAndEnableScrolling 就可以了。您还可以将标签作为元素添加到组中:]
这是一个带有代码的示例:
希望这有帮助,
Blaze
P.S.您可以利用的最简单的东西(据我所知)是 Sprite 类,但 Sprite 不是 IVisualElement。
来自 Flex 文档:
SpriteVisualElement 类是 IVisualElement 接口的一个基于 Sprite 的轻量级实现。 Spark 容器可以布局和渲染 SpriteVisualElement 对象。
另一种解决方案是尝试使用 Spark 基元(s:Rect、s:Line、s:Path)绘制您想要的内容, s:椭圆等)
What you can do is use SpriteVisualElement to draw to, set it's width and height to 100% and put it in a Group. Then enable the Group's property clipAndEnableScrolling and you're all good. You can also add Labels as elements to the group :]
Here is an example with code:
Hope this helps,
Blaze
P.S. The most simple thing you can draw on (as far as I know) is the Sprite class but Sprite is not IVisualElement.
From the Flex documentation:
The SpriteVisualElement class is a light-weight Sprite-based implemention of the IVisualElement interface. Spark containers can lay out and render SpriteVisualElement objects.
Another solution would be to try and draw the things you want to with the spark primitives (s:Rect, s:Line, s:Path, s:Ellipse, etc.)