# Need help with Sound Representation code

**URL:** <https://forum.kirupa.com/t/need-help-with-sound-representation-code/229719>\
**Category:** Uncategorized\
**Created:** [June 19, 2007, 6:51pm UTC](https://forum.kirupa.com/t/need-help-with-sound-representation-code/229719 "2007-06-19T18:51:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mfey](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mfey/32/3661_2.png) [@mfey](https://forum.kirupa.com/u/mfey)\
**Post date:** [June 19, 2007, 6:51pm UTC](https://forum.kirupa.com/t/need-help-with-sound-representation-code/229719/1 "2007-06-19T18:51:10Z")

</div>

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&lt;256;i++) {
            _spectrumGraph.setPixel32(i,20 + spectrum.readFloat() * 20, 0xffffff);
        }
        
        for (var i:int=0;i&lt;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]
