Flex 4:缩放到一点(放大鼠标单击的图像)
我一直在努力让它发挥作用,但我似乎无法弄清楚。有一个 Image
控件,当我单击它时,我需要放大(使用单击鼠标的中心/变换点)。
我的缩放过渡效果很好,但是当我设置 transformX
& tranformY
(autoCenterTransform
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过进一步挖掘,我能够弄清楚这一点。您需要将
MouseEvent
中的transformX
和transformY
设置为舞台坐标(而不是本地坐标)。并像这样修改
Scale
的声明After some further digging, I was able to figure this out. You need to set the
transformX
andtransformY
to the stage coordinates (NOT the local ones) from theMouseEvent
.And modify the declaration for the
Scale
like so