Question

I'm scripting a game with Actionscript 3.0 in Flash Professional CS5.5, but I get an error.

Scene 1, Layer 'as2', Frame 153, Line 4 1151: A conflict exists with definition leftIdle1 in namespace internal.

(I get these with the other Variables too.)

Now it's a platform game, and I am going to put cutscenes throughout in the game and I need to switch from frames and put the code in another frame. But it gives that error, I turned off the 'Automatic Declare stage instances' function, now I checked this website and Googled it, people get it with their Movieclips, I get it with my variables.

This is my script:

var leftKeyDown1:Boolean = false;
var rightKeyDown1:Boolean = false;
var spaceKeyDown1:Boolean = false;
var leftIdle1:Boolean = false;
var rightIdle1:Boolean = true;
var mainSpeed1:Number = 4;


player.addEventListener(Event.ENTER_FRAME, moveChar);
function moveChar(event:Event)
{

    if (leftKeyDown1)
    {
        player.x -=  mainSpeed1;
        leftIdle1 = true;
        rightIdle1 = false;
        player.gotoAndStop("walk_left");
    }
    if (rightKeyDown1)
    {
        player.x +=  mainSpeed1;
        rightIdle1 = true;
        leftIdle1 = false;
        player.gotoAndStop("walk_right");
    }

    if (rightIdle1 && !rightKeyDown1 && !leftKeyDown1)
    {
        player.gotoAndStop("idle_right");
    }
    else if (leftIdle1 && !rightKeyDown1 && !leftKeyDown1)
    {
        player.gotoAndStop("idle_left");
    }

    if (collide.hitTestObject(player))
    {
        player.x = player.x + mainSpeed1;
    }

    if (trigger1.hitTestObject(player))
    {
        son1.gotoAndStop("walkRight");
        trigger1.gotoAndStop(2);
        son1.x +=  2;
    }
    if (trigger2.hitTestObject(player))
    {
        gotoAndPlay(4);
    }
}

stage.addEventListener(KeyboardEvent.KEY_DOWN, checkKeysDown);
function checkKeysDown(event:KeyboardEvent)
{
    if (event.keyCode == 37 || event.keyCode == 65)
    {
        leftKeyDown1 = true;
    }
    if (event.keyCode == 39 || event.keyCode == 68)
    {
        rightKeyDown1 = true;
    }
    if (event.keyCode == 32)
    {
        spaceKeyDown1 = true;
    }
}

stage.addEventListener(KeyboardEvent.KEY_UP, checkKeysU1);
function checkKeysUp(event:KeyboardEvent)
{

    if (event.keyCode == 37 || event.keyCode == 65)
    {
        leftKeyDown1 = false;
    }
    if (event.keyCode == 32)
    {
        spaceKeyDown1 = false;
    }
    if (event.keyCode == 39 || event.keyCode == 68)
    {
        rightKeyDown1 = false;
    }

}

It's probably coded in a weird way, but whatever. I have no idea what to do at this point. Help would be really appreciated.

EDIT:

Oh I got another error too. It's with Duplicate function, and I can't seem to fix it but to rename those, and it will take a long time to rename them every-time. So if someone has something for that, thanks!

Was it helpful?

Solution

you have duplicated definitions.

For example:

var leftIdle1:Boolean

exists multiple times - remove the duplicates

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top