when I try to make a addEventListener I get an error:
Line 20 1046: Type was not found or was not a compile-time constant: Event.
package player {
import flash.media.Sound;
import flash.net.URLRequest;
public class Stream {
private var _Sound = null;
private var _Channel = null;
function Stream(){
this._Sound = new Sound();
}
public function play(url){
this._Sound.load(new URLRequest(url));
this._Channel = this._Sound.play();
this.addEventListener(Event.ENTER_FRAME, this.myFunction);
}
private function myFunction(e:Event){
}
}
}
import flash.events.Event;goes at the top underpackage player {.You need to import the event before using it.
Update:
Use this code. Generally, you want to add an
ENTER_FRAMEevent to a display object. TheSpriteclass is a display object. I’m making it aSpriteby using theextendskeyword. Please note that you need to import the class you’re extending, as I’ve done.