Quantcast
Channel: Adobe Community : All Content - Adobe Animate CC - General
Viewing all articles
Browse latest Browse all 13519

Errors in Maze Wall in Flash Game

$
0
0

Hi - I put in the codes for the upPressed, downPressed, rightPressed, and leftPressed (to test it) and these are the errors that came up. (these are the errors for the (upPressed) but the other keys are having the same errors.  I put the font in bold text the errors lines starts with.  My goal is to not have the car go through the wall --which it still does.  Could someone please let me know how to fix the errors, thanks.   

Errors:

 

Scene 1, Layer 'Actions', Frame 1, Line 1101120: Access of undefined property speed.
Scene 1, Layer 'Actions', Frame 1, Line 1101120: Access of undefined property i.
Scene 1, Layer 'Actions', Frame 1, Line 1101120: Access of undefined property i.
Scene 1, Layer 'Actions', Frame 1, Line 1141120: Access of undefined property wallhitBool.
Scene 1, Layer 'Actions', Frame 1, Line 1121120: Access of undefined property i.
Scene 1, Layer 'Actions', Frame 1, Line 1101120: Access of undefined property i.

 

Here is the program:

 

import flash.events.KeyboardEvent;

stop();

 

/* Move with Keyboard Arrows

Allows the specified symbol instance to be moved with the keyboard arrows.

 

Instructions:

1. To increase or decrease the amount of movement, replace the number 5 below with the number of pixels you want the symbol instance to move with each key press.

Note the number 5 appears four times in the code below.

*/

wallDet1_mc.enabled= false;

wallDet2_mc.enabled= false;

wallDet3_mc.enabled= false;

wallDet4_mc.enabled= false;

wallDet5_mc.enabled= false;

wallDet6_mc.enabled= false;

wallDet7_mc.enabled= false;

wallDet8_mc.enabled= false;

wallDet9_mc.enabled= false;

wallDet10_mc.enabled= false;

var upPressed:Boolean = false;

var downPressed:Boolean = false;

var leftPressed:Boolean = false;

var rightPressed:Boolean = false;

 

carP_mc.addEventListener(Event.ENTER_FRAME, fl_MoveInDirectionOfKey_3);

stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed_3);

stage.addEventListener(KeyboardEvent.KEY_UP, fl_UnsetKeyPressed_3);

stage.addEventListener(Event.ENTER_FRAME, everyFrame);

 

function fl_MoveInDirectionOfKey_3(event:Event)

{

    if (upPressed)

    {

        carP_mc.y -= 5;

    }

    if (downPressed)

    {

        carP_mc.y += 5;

    }

    if (leftPressed)

    {

        carP_mc.x -= 5;

    }

    if (rightPressed)

    {

        carP_mc.x += 5;

    }

}

 

function fl_SetKeyPressed_3(event:KeyboardEvent):void

{

    switch (event.keyCode)

    {

        case Keyboard.UP:

        {

            upPressed = true;

            break;

        }

        case Keyboard.DOWN:

        {

            downPressed = true;

            break;

        }

        case Keyboard.LEFT:

        {

            leftPressed = true;

            break;

        }

        case Keyboard.RIGHT:

        {

            rightPressed = true;

            break;

        }

    }

}

 

function fl_UnsetKeyPressed_3(event:KeyboardEvent):void

{

    switch (event.keyCode)

    {

        case Keyboard.UP:

        {

            upPressed = false;

            break;

        }

        case Keyboard.DOWN:

        {

            downPressed = false;

            break;

        }

        case Keyboard.LEFT:

        {

            leftPressed = false;

            break;

        }

        case Keyboard.RIGHT:

        {

            rightPressed = false;

            break;

        }

    }

    }

function everyFrame(event:Event):void {

var mazehit:Boolean = false;

if (upPressed) {

 

mazehit=false

 

for(i = 0; i < speed; i++) {

 

if(carP_mc.hitTestObject(this["wallDet"+i+"_mc"])){

 

wallhitBool=true;

 

break;

 

}

 

if(mazehit){

 

carP_mc.x += 5;

 

}

}

}

if (downPressed) {

mazehit=false

 

for(i = 0; i < speed; i++) {

 

if(carP_mc.hitTestObject(this["wallDet"+i+"_mc"])){

 

wallhitBool=true;

 

break;

 

}

 

if(mazehit){

 

carP_mc.x -= 5;

}

}

if (leftPressed) {

mazehit=false

 

for(i = 0; i < speed; i++) {

 

if(carP_mc.hitTestObject(this["wallDet"+i+"_mc"])){

 

wallhitBool=true;

 

break;

 

}

 

if(mazehit){

 

carP_mc.x += 5;

}

}

if (rightPressed) {

mazehit=false

 

for(i = 0; i < speed; i++) {

 

if(carP_mc.hitTestObject(this["wallDet"+i+"_mc"])){

 

wallhitBool=true;

 

break;

 

}

 

if(mazehit){

 

carP_mc.x -= 5;

}

}

}

/**onClipEvent(enterFrame){

    if(this.hitArea(carP_mc._x,carP_mc._y, true)){                   

      

        carP_mc._x=carP_mc._x;

        carP_mc._y=carP_mc._y;

    }

}**/

 

//Keyboard Listener on stage

//stage.addEventListener(KeyboardEvent.KEY_DOWN, theKeysDown);

//stage.addEventListener(KeyboardEvent.KEY_UP, theKeysUp);

 

 

//Makes MazeArt follow the movement of the path_mc

 

/*addEventListener(Event.ENTER_FRAME, onNewFrame01);

 

function onNewFrame01(e:Event):void{

    maze_mc.x=wallDet1_mc.x;

    maze_mc.y=wallDet1_mc.y

}

}

function Car_P(e:KeyboardEvent):void

{

 

    //maze_mc.addEventListener(KeyboardEvent, wallDet1_mc);

 

}

    //wallDet1_mc.addEventListener(KeyboardEvent.KEY_DOWN, maze_mc);

*/

//}


Viewing all articles
Browse latest Browse all 13519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>