动态调整绝对绘制的 Flex 4 组件的大小(由 Catalyst 生成的绘制代码)

发布于 2024-08-21 02:38:32 字数 1053 浏览 8 评论 0原文

我有一些由 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:

http://gist.github.com/300207

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

短叹 2024-08-28 02:38:32

这是可行的:

<s:Group id="windmill" width="50" height="200" x="400" y="400">
    <s:Group id="windmillBlades" resizeMode="scale" width="100%" height="100%">
         <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>

<s:VGroup>
    <s:HSlider id="scaler"
        minimum=".1" maximum="2" snapInterval=".01"
        valueCommit="{windmill.scaleX = windmill.scaleY = scaler.value}"/>
    <s:HSlider id="rotator"
        minimum="0" maximum="360" snapInterval="1"
        valueCommit="{windmill.rotation = rotator.value}"/>
</s:VGroup>

我不确定制作完整风车的最佳方法(使用 s:Line 等,可能只是一个中继器?),但这是旋转风车的好方法。不必旋转每一行(大量计算),只需旋转整个组即可。如果 windmillBladles 宽度和高度为 100%,它们将自动随 Group 一起缩放。

如果你想让每个叶片单独绕其中心旋转,那就困难得多。幸运的是,有 ILayoutElement#transformAround 方法(UIComponent 具有),它允许您围绕任意中心旋转/缩放/变换。如果听起来更好的话,请尝试使用它。

祝你好运,

This works:

<s:Group id="windmill" width="50" height="200" x="400" y="400">
    <s:Group id="windmillBlades" resizeMode="scale" width="100%" height="100%">
         <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>

<s:VGroup>
    <s:HSlider id="scaler"
        minimum=".1" maximum="2" snapInterval=".01"
        valueCommit="{windmill.scaleX = windmill.scaleY = scaler.value}"/>
    <s:HSlider id="rotator"
        minimum="0" maximum="360" snapInterval="1"
        valueCommit="{windmill.rotation = rotator.value}"/>
</s:VGroup>

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文