A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: [RESOLVED] Error 1009 appearing attempting to play Sound

  1. #1
    Senior Member
    Join Date
    Jul 2000
    Posts
    373

    resolved [RESOLVED] Error 1009 appearing attempting to play Sound

    Haven't had an Error 1009 issue in awhile but tonight I got one trying to play an external .mp3 track. Seems i got a null object somewhere but I can't seem to locate it. After debugging, it seems to be an error in my playBtn reference but it seems have all the proper instances. Any idea where the problem may lie?

    Here's the code:

    Code:
    import flash.media.SoundChannel;
    
    stop();
    pauseBtn.visible = false;
    var snd:Sound = new Sound();
    var myChannel:SoundChannel = new SoundChannel();
    var lastPosition:Number = 0;
    snd.load(new URLRequest("someAudio.mp3"));
    
    pauseBtn.addEventListener(MouseEvent.CLICK, onClickPause);
    function onClickPause(e:MouseEvent):void
    {
    	lastPosition = myChannel.position;
    	myChannel.stop();
    	pauseBtn.visible = false;
    	playBtn.visible = true;
    }
    
    playBtn.addEventListener(MouseEvent.CLICK, onClickPlay);
    
    function onClickPlay(e:MouseEvent):void
    {
    	myChannel = snd.play(lastPosition);
    	pauseBtn.visible = true;
    	playBtn.visible = false;
    }
    Adam Bell
    dzign@datatv.com
    --
    Over 90% of all websites
    suck......
    Join the minority.

  2. #2
    Senior Member
    Join Date
    Jan 2009
    Posts
    208
    add trace in here:

    Actionscript Code:
    function onClickPause(e:MouseEvent):void
    {

    trace(myChannel);
        lastPosition = myChannel.position;
        myChannel.stop();
        pauseBtn.visible = false;
        playBtn.visible = true;
    }

  3. #3
    Lunatic
    Join Date
    Nov 2002
    Location
    AS3 Forum
    Posts
    342
    Like regbol said, try tracing all your objects:

    trace(myChannel);
    trace(snd);
    trace(playBtn);
    trace(pauseBtn);

    One will come up null.

  4. #4
    Senior Member
    Join Date
    Jul 2000
    Posts
    373
    You mean like this?

    Code:
    pauseBtn.addEventListener(MouseEvent.CLICK, onClickPause);
    function onClickPause(e:MouseEvent):void
    {
    	trace(myChannel);
    	trace(snd);
    	trace(playBtn);
    	trace(pauseBtn);
    	lastPosition = myChannel.position;
    	myChannel.stop();
    	pauseBtn.visible = false;
    	playBtn.visible = true;
    }
    Because nothing changed. Just the same error 1009 and no additional information.
    Adam Bell
    dzign@datatv.com
    --
    Over 90% of all websites
    suck......
    Join the minority.

  5. #5
    Lunatic
    Join Date
    Nov 2002
    Location
    AS3 Forum
    Posts
    342
    Can you find out exactly what line throws that error? If I had to guess right now I'm assuming your playBtn or your pauseBtn doesn't have an instance name in it's properties on the stage.

  6. #6
    Senior Member
    Join Date
    Jul 2000
    Posts
    373
    Yea, after using the debugger, it's

    playBtn.addEventListener(MouseEvent.CLICK, onClickPlay);

    Which makes no sense since there is an instance of playBtn on the stage.
    Adam Bell
    dzign@datatv.com
    --
    Over 90% of all websites
    suck......
    Join the minority.

  7. #7
    Lunatic
    Join Date
    Nov 2002
    Location
    AS3 Forum
    Posts
    342
    Yeah but did you name the instance in the properties panel?

    Refer to attached picture.
    Attached Images Attached Images

  8. #8
    Senior Member
    Join Date
    Jul 2000
    Posts
    373
    Yes and No. Actually, that let me figure it out. I did place the instance of playBtn in the properties panel but only for the conclusion of the tween. Not the start. That's where the error was and I hate you have to do it twice to make the button work. But it works and I thank you Beathoven for the answer.
    Adam Bell
    dzign@datatv.com
    --
    Over 90% of all websites
    suck......
    Join the minority.

  9. #9
    Lunatic
    Join Date
    Nov 2002
    Location
    AS3 Forum
    Posts
    342
    Perfect. Don't forget to mark the thread resolved then. (Top right, thread tools ->*Mark Thread Resolved)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center