Hi,
I’m VERY new to AS3, and I’m trying to crate a visual representation of an mp3. Here’s the class code, which I’m putting in an external .as file in the same folder as the .fla:
[COLOR=Navy]
[/COLOR][COLOR=Navy]package {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.event;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.net.URLRequest;
import flash.utils.ByteArray;
public class Spectrum extends Sprite {
private var _sound:Sound;
private var _channel:SoundChannel;
private var _spectrumGraph:BitmapData;
public function Spectrum(){
_spectrumGraph = new BitmapData(256, 60, true, 0x000000);
var bitmap:BitmapData = new Bitmap(_spectrumGraph);
addChild(bitmap);
bitmap.x = 10;
bitmap.y = 10;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
_sound = new Sound(new URLRequest("beat2.mp3"));
_channel = _sound.play();
}
public function onEnterFrame(event:Event):void
{
var spectrum:ByteArray = new ByteArray();
SoundMixer.computeSpectrum(spectrum);
_spectrumGraph.fillRect(_spectrumGraph.rect,0x000000);
for (var i:int=0;i<256;i++) {
_spectrumGraph.setPixel32(i,20 + spectrum.readFloat() * 20, 0xffffff);
}
for (var i:int=0;i<256;i++) {
_spectrumGraph.setPixel32(i,40 + spectrum.readFloat() * 20, 0xffffff);
}
}
}
}[/COLOR]
Then, in the main timeline on the first keyframe of the .fla I have this:
[COLOR=Navy]import Spectrum;
var newSpect:Spectrum = new Spectrum();[/COLOR]
I keep getting this error:
[COLOR=Navy]1046: Type was not found or was not a compile-time constant: Event.
[COLOR=Black]Any help is much appreciated[/COLOR]
[/COLOR]