旋转 AS3 动态创建的对象
我正在构建一个需要使用均衡器播放音频文件的网站。 我对 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在线下方:
尝试添加:
我相信这应该可行,但是您可能会遇到枢轴点位置的一些问题(无论您希望它绕中心还是绕左上角旋转 90 度)。
Right below the lines:
Try adding:
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).
另一件要记住的事情是 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.