Ekai Hafiz
Ekai Hafiz

Reputation: 1

A conflict exists with definition event in namespace internal

I am new in as3. I get this error:

A conflict exists with definition event in namespace internal.

I'm using same coding but different scene. I changed second scene.

var mysound:bila =new bila()

This is the code of my 1st scene, and success only in 1st scene:

var isItPlaying:Boolean = true;
var lastposition:Number = 0;
var mysound:izhar = new izhar();
var soundchannel:SoundChannel = new SoundChannel();
soundchannel = mysound.play(0,0);// playing sound in the channel
soundchannel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete1);

function onPlaybackComplete1(event:Event):void
{
    lastposition = 0;
    soundchannel.stop();
    btn.btn_pause.visible = false;
    trace("finished");
    isItPlaying=false;
}
/************end of part 1********/

btn.addEventListener(MouseEvent.CLICK, playsound);*

function playsound(event:MouseEvent):void*
{
    if (! isItPlaying)
    {
        soundchannel = mysound.play(lastposition,0);
        btn.btn_pause.visible = true;
        isItPlaying = true;
    }
    else
    {
        lastposition = soundchannel.position;
        soundchannel.stop();
        btn.btn_pause.visible = false;
        /*trace(lastposition.toFixed(0), mysound.length.toFixed(0));*/
        isItPlaying = false;
    }

    soundchannel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);*

    function onPlaybackComplete(event:Event):void
    {
        lastposition = 0;
        soundchannel.stop();
        btn.btn_pause.visible = false;
        trace("finished");
        isItPlaying=false;
    }
}

Upvotes: 0

Views: 425

Answers (1)

Cadin
Cadin

Reputation: 4649

The conflict is because you are declaring two variables with the same name in the same scope.

You declare the event variable as a parameter in your playsound function. Then you have a nested function onPlaybackComplete that declares a parameter with the same name.

To fix this, either rename one of the parameters to something else, or move the onPlaybackComplete function outside the playsound function so it has its own scope.

I'd prefer the second option, unless you need have that function nested for some specific reason.

Upvotes: 2

Related Questions