0
votes

I am currently trying to put together a platformer game similar to doodlejump however I am getting two errors that I am unsure of how to fix. Below is the code that I am currently using. My errors are;

**Scene 1, Layer 'Code', Frame 4, Line 181 1046: Type was not found or was not a compile-time constant: stick.


Scene 1, Layer 'Code', Frame 4, Line 207 1180: Call to a possibly undefined method stick.**


var tempStick:stick;
var tmpMc:MovieClip;


stop();

// MONITOR THE ACCELEROMETER
var myAcc:Accelerometer = new Accelerometer();
myAcc.addEventListener(AccelerometerEvent.UPDATE, onAccUpdate);

function onAccUpdate(evt:AccelerometerEvent):void{
    accX = evt.accelerationX;   
}

//MONITOR THE ENTER_FRAME EVENT
stage.addEventListener(Event.ENTER_FRAME, onMyEnterFrame);

//INIT STAGE WITH CLOUDS
if (firstPass == 1){
    liveScore = 0;
    accX = 0;

    for (var i:int=0; i< 5; i++){
    tempStick = new stick;
    tempStick.x = Math.random()*stage.stageWidth;
    tempStick.y = 0 + i*stage.stageHeight/6;

    myVect[i] = tempStick;
    addChild(tempStick);
    tempStick.cacheAsBitmap = true;
}
    firstPass = 2;
}




function onMyEnterFrame(evt:Event):void{

//MOVE X DEPENDING ON THE ACCELEROMETER
MyIcare.x -= (MyIcare.x - (MyIcare.x + accX * 10))*0.6;

//MOVE HEAD TO THE LEFT OR TO THE RIGHT
if(accX > 0) {
    MyIcare.gotoAndStop(2);
}else{
    MyIcare.gotoAndStop(1);
}

// Vertical speed OF THE ICARE/ANGEL
vVelocity += vAcceleration;



if((MyIcare.y > middleScreen) && (vVelocity < 0)){
        // ICARE IS GOING UP
        MyIcare.y += vVelocity;
    }else{
        if(vVelocity > 0){
            // ICARE IS GOING DOWN
            MyIcare.y += vVelocity;

            // TEST IF ICARE TOUCHES A CLOUD
            for (var i:int=0; i< 5; i++){
                tmpMc = myVect[i];
                if (MyIcare.hitTestObject(tmpMc))
                    {
                        vVelocity = -20;
                    }

            }

        }else{
            // THE WORLD IS GOING DOWN
            // WHEN ICARE IS IN THE MIDDLE OF THE SCREEN

            for (var j:int=0; j< 5; j++){
                tmpMc = myVect[j];
                tmpMc.y -=  vVelocity;
            }

            liveScore += 5;
        }
    }

    // CHECK IF THE CLOUDS ARE OUT OF THE SCREEN
    if(myVect[0] != null){
    for (var k:int=0; k< 5; k++){
                tmpMc = myVect[k];
                if(tmpMc.y > stage.stageHeight){
                    tmpMc.y = -5;
                    tmpMc.x =  Math.random()*stage.stageWidth;
                }
            }
    }


    //ICARE IS OUT OF THE SCREEN

        //PAUSE GAME
        MyIcare.y = -300;
        vVelocity = 0;
        vAcceleration = 0;

        // PLAY FUNNY SOUND
    }
1

1 Answers

0
votes

Most likely your problem is you haven't told your library object (stick) to be accessible to code.

To do that, open your library panel in FlashPro, right click your stick asset/movieClip, and choose properties.

On the Symbol Properties Window, check the Export For ActionScript box. Then enter stick as in the Class field.

Now you can instantiate a stick through code. enter image description here