【问题标题】:Video display rotation position changed视频显示旋转位置已更改
【发布时间】:2015-09-22 01:30:24
【问题描述】:

我正在尝试根据角度旋转视频显示。
我得到了总共 4 个角度 0,-90,90,180。

我按照以下方式进行轮换:

if(videoAngle == 180)
{
    videoDisplay.rotation = 180;                            
}
else if(videoAngle == 90)
{
    videoDisplay.rotation = -90;
}
else if(videoAngle == -90)
{
    videoDisplay.rotation = 90;
}

它旋转了videoDisplay,但它的x 和y 位置发生了变化,heightwidth 也发生了变化。

我尝试了很多东西,但都没有成功。
有什么解决办法吗?

【问题讨论】:

  • I try many things to set it's x and y but didn't succeed. 喜欢什么???..你说旋转工作正常,但你仍然显示工作代码没有问题的代码?如果您有太多问题,我会使用 netStreamVideo 对象,因为这些问题可以更好地控制视频..
  • 有什么解决方案?我不知道你想在这里完成什么。
  • 我尝试了像 videoDisplay.x = 100; 这样的静态/固定值。它会解决问题,但不可靠。

标签: actionscript-3 apache-flex video actionscript


【解决方案1】:

视频对象的旋转点固定在左上角,因此您需要将此视频放入容器(MC 或 Sprite)中,并在视频中心放置“x”和“y”。

你可以在 fla 中做到这一点,也可以在代码中做到这一点:

function putInCenter(display:DisplayObject):Sprite {
    var box:Sprite = new Sprite()
    display.parent.addChild(box)
    box.x = display.x + display.width / 2
    box.y = display.y + display.height / 2
    box.addChild(display)
    display.x = -display.width / 2
    display.y = -display.height / 2
    return box
}

var videoBox:Sprite = putInCenter(videoDisplay)

现在你旋转这个容器而不是“videoDisplay”

if(videoAngle == 180)
{
    videoBox.rotation = 180
}
else if(videoAngle == 90)
{
    videoBox.rotation = -90;
}
else if(videoAngle == -90)
{
    videoBox.rotation = 90;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-27
    • 2012-10-06
    • 1970-01-01
    • 2020-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多