Hi,
with this code (see below) I get this error message:
Error #2044: IOErrorEvent unhandled. text=Error #2032: Stream-Error.
at DocClass2/frame1()
ArgumentError: Error #2068: Invalid Sound.
at flash.media::Sound/play()
at DocClass2/upHandler()
Somehow the two codes (actions frame and document class (attached)) are in conflict, but I don't know
how exactly and how to solve it. Any idea/help?
Thanks in advance.
Code:
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.events.Event;
import flash.net.URLRequest;
var trk1:Sound = new Sound();
var trkChannel1:SoundChannel = new SoundChannel();
var req:URLRequest = new URLRequest("Sound/aleatoric inspiration_2.mp3");
trk1.load(req);
var myTimer:Timer = new Timer(50);
var pos:int;
stage.addEventListener(MouseEvent.MOUSE_DOWN, pressHandler);
//trkChannel1.addEventListener(Event.ENTER_FRAME, onEnterFrame);
myTimer.addEventListener(TimerEvent.TIMER, timerHandler);
function pressHandler(e:Event):void {
stage.addEventListener(MouseEvent.MOUSE_MOVE, moveHandler);
stage.addEventListener(MouseEvent.MOUSE_UP, upHandler);
trkChannel1.stop();
myTimer.stop();
if (mc_arm.rotation > 10) {
mc_vinyl.gotoAndPlay(2);
}
if (mc_arm.rotation < 10) {
mc_vinyl.gotoAndPlay(1);
}
}
function moveHandler(e:Event):void {
if (mc_area.hitTestPoint(mouseX,mouseY,true)) {
mc_arm.rotation=(rotation2(mouseX-mc_arm.x,mouseY-mc_arm.y))-90;
}
// trace(mc_arm.rotation);
}
function upHandler(e:Event):void {
stage.removeEventListener(MouseEvent.MOUSE_UP, upHandler);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, moveHandler);
var starts:Number=(1-((((rotation2(mouseX-mc_arm.x,mouseY-mc_arm.y))-90)-15)/35))*trk1.length;
trkChannel1 = trk1.play(starts);
// trace(starts);
myTimer.start();
if (mc_arm.rotation > 10) {
mc_vinyl.gotoAndPlay(2);
}
if (mc_arm.rotation < 10) {
mc_vinyl.gotoAndPlay(1);
}
}
function timerHandler (e:TimerEvent):void {
pos = Math.floor(trkChannel1.position);
mc_arm.rotation = 50 - ((pos/252935)*34);
}
function rotation2(dx:Number, dy:Number):Number {
return Math.atan2(dy, dx) * (180/Math.PI);
}