1120:访问未定义的属性clickBt

时间:2013-04-09 23:12:24

标签: flash cs3

我正在尝试制作游戏,使用Flash CS3,我是CS3中的新手.. 有人请帮帮我。

在我的代码中,我遇到了这个错误:

  

第17行1120:访问未定义的属性clickBt。


package  {
import flash.events.MouseEvent;

public class StartScreen {
    public var b:Bt;
    public var ref:main;

    public function StartScreen(r:main) {
        ref = r;
        startScreen();
    }

    public function startScreen(){
        b = new Bt();
        b.x = 200; b.y = 200;
        b.buttonMode =true;
        b.addEventListener(MouseEvent.CLICK,clickBt);
        ref.stage.addChild(b);
    }

Class main

package  {

import flash.display.MovieClip;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;   

public class main extends MovieClip {
    var s:StartScreen;

    var bg:Bg;
    var player:Karma;
    var playerScale:int = 1;
    var playerAnim:String;
    var playerSpeed:int = 0;


    var isLeft:Boolean = false;
    var isRight:Boolean = false;
    var isStrike:Boolean = false;
    var isJump:Boolean = false;
    var isShot:Boolean=false;


    public function main() {
        loadStartScreen();

        bg = new Bg;
        addChild(bg);
        player = new Karma;


        //centraliza karma na tela
        player.y = (stage.stageHeight/2) + (player.height/2);
        player.x = stage.stageWidth/2;

        //insere karma na tela
        addChild(player);

        //eventos de teclado
        stage.addEventListener(KeyboardEvent.KEY_DOWN,kDown);       
        stage.addEventListener(KeyboardEvent.KEY_UP,kUp);       

        //evento ENTER_FRAME (looping do game)
        stage.addEventListener(Event.ENTER_FRAME,gLoop);    
    }
    function loadStartScreen(){
        s = new StartScreen(this);
    }
    public function kDown(e:KeyboardEvent){
        var code:int = e.keyCode;
        if(code == Keyboard.LEFT){
            isLeft = true;
        }
        if(code == Keyboard.RIGHT){
            isRight = true;
        }
        if(code == Keyboard.SPACE){
            isStrike = true;
                        }
        if(code == Keyboard.UP){
            isJump = true;
        }
}
    public function kUp(e:KeyboardEvent){
        var code:int = e.keyCode;
        if(code == Keyboard.LEFT){
            isLeft = false;
        }
        if(code == Keyboard.RIGHT){
            isRight = false;
        }
        /*if(code == Keyboard.SPACE){
            isStrike = false;
        }*/
        /*if(code == Keyboard.UP){
            isJump = false;
        }*/

}
    public function gLoop(e:Event){

        if(!isLeft && !isRight || isLeft && isRight){ 
                playerSpeed = 0;
                playerAnim = "Stand";
            }else if(isLeft){
                playerSpeed = -7;
                playerScale = -1;
                playerAnim = "Walk";
            }else if(isRight){
                playerSpeed = 7;
                playerScale = 1;
                playerAnim = "Walk";
            }if(isStrike){
                playerSpeed = 0;
                playerAnim = "Strike";
                if(player.anim.currentFrame == player.anim.totalFrames){
                    isStrike = false;                       

                }
            }if(isJump){

                playerAnim = "Jump";
                if(player.anim.currentFrame == 15){
                    isJump = false;

                }
                    }
            player.x += playerSpeed
            player.scaleX = playerScale;
            player.gotoAndStop(playerAnim);
    }
    }
}

1 个答案:

答案 0 :(得分:1)

看起来clickBt未定义。创建clickBt功能,你应该是金色的!