图像在 Flex 中旋转 3D,但在该图像的背面显示另一个图像?

发布于 2024-12-11 16:08:46 字数 197 浏览 0 评论 0原文

我想在 Flex 中旋转 3D 名为 img1 的图像。我想将它绕y轴旋转180度。我可以通过使用 Flex 中内置的 3D 效果来做到这一点,但我想做更多不同的事情。

我希望在旋转过程中,img1的背面出现另一个名为img2的图像(默认情况下,背面出现的图像是img1),并且当旋转完成时,图像将是img2。

我该怎么做?

谢谢。

i want to rotate 3D an Image called img1 in Flex. I want to rotate it around y axis 180 degree. I can do this by using 3D effect already built in Flex but i want to do a bit more different.

I want during rotating, there's another image called img2 appear on back of img1 (in default case, the image appear on the back is img1) and when rotating finish, the image will be img2.

How can i do this ?

Thank you.

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

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

发布评论

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

评论(2

灼痛 2024-12-18 16:08:46

如果你不需要透视效果,这很容易做到。一个粗略的实现(未测试!):

// Event.ENTER_FRAME event listener
void on_enter_frame(event:Event):void
{
   // m_angle is a member of the class/flex component where on_enter_frame is declared
   // ANGLE_DELTA is just a constant
   m_angle += ANGLE_DELTA;
   // Angle clamping to the range [0, PI * 2)
   m_angle %= Math.PI * 2;
   if (m_angle < 0)
      m_angle += Math.PI * 2;

   // If we currently look at the front side...
   if (m_angle < Math.PI)
   {
      img1.visible = true;
      img2.visible = false;
      img1.scaleX = Math.cos(m_angle);
   }
   else
   {
      img1.visible = false;
      img2.visible = true;
      // If you omit negation, the back-side image will be mirrored
      img2.scaleX = -Math.cos(m_angle);
   } 
}

所以每一帧我们都会增加旋转角度,将其限制在 [0, PI * 2) 范围内。然后根据旋转角度的值,我们隐藏/显示一对图像,然后对可见图像执行 x 缩放。

If you need no perspective effect, it's quite easy to do. A rough implementation (not tested!):

// Event.ENTER_FRAME event listener
void on_enter_frame(event:Event):void
{
   // m_angle is a member of the class/flex component where on_enter_frame is declared
   // ANGLE_DELTA is just a constant
   m_angle += ANGLE_DELTA;
   // Angle clamping to the range [0, PI * 2)
   m_angle %= Math.PI * 2;
   if (m_angle < 0)
      m_angle += Math.PI * 2;

   // If we currently look at the front side...
   if (m_angle < Math.PI)
   {
      img1.visible = true;
      img2.visible = false;
      img1.scaleX = Math.cos(m_angle);
   }
   else
   {
      img1.visible = false;
      img2.visible = true;
      // If you omit negation, the back-side image will be mirrored
      img2.scaleX = -Math.cos(m_angle);
   } 
}

So every frame we increase the rotation angle, clamp it to the range [0, PI * 2). Then depending on the value of the rotation angle, we hide/show the pair of your images, and then perform x-scaling of the visible image.

白色秋天 2024-12-18 16:08:46

谢谢你,现在我找到了解决方案。请检查这里,这很容易做到。

http://forums.adobe.com/thread/921258

Thank you, now i found a solution. Please check it here, it's very easy to do.

http://forums.adobe.com/thread/921258

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