旋转 AS3 动态创建的对象

发布于 2024-07-13 01:37:13 字数 1475 浏览 6 评论 0原文

我正在构建一个需要使用均衡器播放音频文件的网站。 我对 AS3 还不太了解,所以这可能是一个简单的问题。

我找到了一个我想使用的示例 此处演示此处的源文件

将均衡器对象添加到舞台的代码(来自教程)

package {
    import flash.media.*;
    import flash.net.*;
    import flash.display.*;
    import flash.events.*;

    import com.everydayflash.equalizer.*;
    import com.everydayflash.equalizer.color.*;

    public class Main extends Sprite{
        public function Main() {
            var s:Sound = new Sound(new URLRequest("track.mp3"));
            s.play(0, 100, new SoundTransform(1, 0));

            var es:EqualizerSettings = new EqualizerSettings();
            es.numOfBars = 32;
            es.height = 64;
            es.barSize = 2;
            es.vgrid = true;
            es.hgrid = 2;
            es.colorManager = new SolidBarColor(0xffff4444);
            es.effect = EqualizerSettings.FX_REFLECTION;

            var e:Equalizer = new Equalizer();
            e.update(es);
            e.x = 100;
            e.y = 100;
            addChild(e);

            addEventListener(Event.ENTER_FRAME, e.render);
        }
    }
}

这将创建一个垂直方向的均衡器,并具有一些非常好的效果。

然而我希望它是水平的,所以我相信我需要将“e”旋转90度。 你们有人知道该怎么做吗? 或者方向完全由创建它的动作脚本决定?

感谢您提供的任何帮助。

I'm building a site that requires an audio file to be played with an equalizer. I don't know alot about AS3 yet so this might be a simple question.

I've found an example that I would like to use Demonstrated here and the source files here

The code to add the equalizer object to the stage (from the tutorial)

package {
    import flash.media.*;
    import flash.net.*;
    import flash.display.*;
    import flash.events.*;

    import com.everydayflash.equalizer.*;
    import com.everydayflash.equalizer.color.*;

    public class Main extends Sprite{
        public function Main() {
            var s:Sound = new Sound(new URLRequest("track.mp3"));
            s.play(0, 100, new SoundTransform(1, 0));

            var es:EqualizerSettings = new EqualizerSettings();
            es.numOfBars = 32;
            es.height = 64;
            es.barSize = 2;
            es.vgrid = true;
            es.hgrid = 2;
            es.colorManager = new SolidBarColor(0xffff4444);
            es.effect = EqualizerSettings.FX_REFLECTION;

            var e:Equalizer = new Equalizer();
            e.update(es);
            e.x = 100;
            e.y = 100;
            addChild(e);

            addEventListener(Event.ENTER_FRAME, e.render);
        }
    }
}

This creates a vertically oriented equalizer with some pretty nice effects.

However I would like it to be horizontal so I believe I need to rotate "e" 90 degrees. Do any of you know how to do this? Or is the orientation dictated exclusively by the action script that creates it?

Thanks for any help you have.

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

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

发布评论

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

评论(2

青芜 2024-07-20 01:37:13

在线下方:

e.x = 100;
e.y = 100;

尝试添加:

e.rotation = 90;

我相信这应该可行,但是您可能会遇到枢轴点位置的一些问题(无论您希望它绕中心还是绕左上角旋转 90 度)。

Right below the lines:

e.x = 100;
e.y = 100;

Try adding:

e.rotation = 90;

I believe that should work, but you may run into some issues with the location of the pivot point (whether you want it rotated 90 degrees around the center, or around the top left).

梦醒灬来后我 2024-07-20 01:37:13

另一件要记住的事情是 DisplayObject.transform.matrix(Sprite 间接扩展 DisplayObject)。 您可以使用矩阵转换来执行许多操作如果需要,可以进行更复杂的平移/旋转/缩放。

Another thing to keep in mind is DisplayObject.transform.matrix (Sprite extends DisplayObject indirectly). You can use matrix transformations to do much more complex translation/rotation/scaling if you need it.

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