动态调整绝对绘制的 Flex 4 组件的大小(由 Catalyst 生成的绘制代码)
我有一些由 Flash Catalyst 生成的代码,我需要它可调整大小和大小。可旋转。
目前,我不知道如何实现这一点。
基本思想是:
- 我有一个风车。
- windmill 包含 windmillBlades。
- 风车叶片旋转。
- 风车调整大小。
- 当风车调整大小时,windmillBlades应随风车动态缩放。
下面的代码是以下代码的简化概要我准备的演示应用程序的结构,准备粘贴到您的IDE中:
http://gist.github.com/ 300207
请查看 来源并看看你是否可以提供帮助 因为这是关键任务 为我。 :/
<s:Group id="windmill" width="50" height="200">
<s:Group id="windmillBlades" resizeMode="scale" verticalCenter="0" horizontalCenter="0">
<s:Line xFrom="0" xTo="140" yFrom="0" yTo="140">
<s:stroke>
<s:SolidColorStroke color="0xBC311E" weight="16" />
</s:stroke>
</s:Line>
</s:Group>
</s:Group>
谢谢!
编辑:请注意,这是我真实应用程序的抽象,我不是在构建风车模拟器。
I have some code generated by Flash Catalyst, and I need it to be resizable & rotatable.
At the moment, I have no idea how to get this to happen.
The basic idea is:
- I have a windmill.
- windmill contains windmillBlades.
- windmillBlades rotate.
- windmill resizes.
- When the windmill resizes, the windmillBlades should scale dynamically with the windmill.
The code below is a simplified outline of the structure of a demo app I prepared, ready to paste into your ide:
Please check out
the source and see if you can help
because this is mission critical
for me. :/
<s:Group id="windmill" width="50" height="200">
<s:Group id="windmillBlades" resizeMode="scale" verticalCenter="0" horizontalCenter="0">
<s:Line xFrom="0" xTo="140" yFrom="0" yTo="140">
<s:stroke>
<s:SolidColorStroke color="0xBC311E" weight="16" />
</s:stroke>
</s:Line>
</s:Group>
</s:Group>
Thanks!
edit: Note this is an abstraction of my real app, I'm not building a windmill simulator.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是可行的:
我不确定制作完整风车的最佳方法(使用 s:Line 等,可能只是一个中继器?),但这是旋转风车的好方法。不必旋转每一行(大量计算),只需旋转整个组即可。如果
windmillBladles
宽度和高度为 100%,它们将自动随 Group 一起缩放。如果你想让每个叶片单独绕其中心旋转,那就困难得多。幸运的是,有
ILayoutElement#transformAround
方法(UIComponent 具有),它允许您围绕任意中心旋转/缩放/变换。如果听起来更好的话,请尝试使用它。祝你好运,
槊
This works:
I'm not to sure the best way to make a full windmill (with s:Line and all, probably just a repeater?), but this is a good way for rotating the windmill. Instead of rotating every line (lots of calculations), just rotate the whole group. And if the
windmillBladles
width and height are 100%, they will automatically scale with the Group.If you want to make the blades each individually rotate around their center, that's a lot harder. Luckily there's the
ILayoutElement#transformAround
method (which UIComponent has), which allows you to rotate/scale/transform around an arbitrary center. Try using that if that sounds better.Good luck,
Lance