Flex 4:缩放到一点(放大鼠标单击的图像)

发布于 2024-09-05 15:00:57 字数 936 浏览 3 评论 0原文

我一直在努力让它发挥作用,但我似乎无法弄清楚。有一个 Image 控件,当我单击它时,我需要放大(使用单击鼠标的中心/变换点)。

我的缩放过渡效果很好,但是当我设置 transformX & tranformYautoCenterTransform false)它不会放大到该点。

这是我的代码,仅放大(不放大到特定点)

<fx:Script>
        <![CDATA[

            protected function imgLogo_clickHandler(event:MouseEvent):void
            {
                transformer.play();
            }           
        ]]>
    </fx:Script>

    <fx:Declarations>       
        <s:Parallel id="transformer" target="{imgLogo}">
            <s:Scale scaleXBy="0.5" scaleYBy="0.5" />           
        </s:Parallel>
    </fx:Declarations>

    <mx:Image id="imgLogo"   width="250" x="100" y="100"
            maintainAspectRatio="true" source="@Embed('src/logo.png')"      
            click="imgLogo_clickHandler(event)"  />

非常感谢任何帮助。 谢谢

I've been trying to get this working and I can't seem to figure it out. There is an Image control that when I click on it I need to zoom in (using the center/transform point where the mouse is clicked).

I have the zoom transition working great, but when I set transformX & tranformY (with autoCenterTransform false) it doesn't zoom into that point.

Here is my code that only zooms in (not to a specific point)

<fx:Script>
        <![CDATA[

            protected function imgLogo_clickHandler(event:MouseEvent):void
            {
                transformer.play();
            }           
        ]]>
    </fx:Script>

    <fx:Declarations>       
        <s:Parallel id="transformer" target="{imgLogo}">
            <s:Scale scaleXBy="0.5" scaleYBy="0.5" />           
        </s:Parallel>
    </fx:Declarations>

    <mx:Image id="imgLogo"   width="250" x="100" y="100"
            maintainAspectRatio="true" source="@Embed('src/logo.png')"      
            click="imgLogo_clickHandler(event)"  />

Any help is greatly appreciated.
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

倥絔 2024-09-12 15:00:57

经过进一步挖掘,我能够弄清楚这一点。您需要将 MouseEvent 中的 transformXtransformY 设置为舞台坐标(而不是本地坐标)。

protected function imgLogo_clickHandler(event:MouseEvent):void
{
     scaleImg.transformX = event.stageX;
     scaleImg.transformY = event.stageY;
     transformer.play();
}  

并像这样修改 Scale 的声明

<s:Scale id="scaleImg" scaleXBy="0.5" scaleYBy="0.5" autoCenterTransform="false" />    

After some further digging, I was able to figure this out. You need to set the transformX and transformY to the stage coordinates (NOT the local ones) from the MouseEvent.

protected function imgLogo_clickHandler(event:MouseEvent):void
{
     scaleImg.transformX = event.stageX;
     scaleImg.transformY = event.stageY;
     transformer.play();
}  

And modify the declaration for the Scale like so

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