views:

3432

answers:

2

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.

+3  A: 

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).

Chad Birch
Perfect, thank you... I'd tried e.rotate and got errors but rotation did the trick.
Birk
You were right about the pivot point too so I just kept playing with the numbers till it worked out... thanks again.
Birk
+1  A: 

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.

Richard Szalay
Good to note, thanks.
Birk