0

我正在尝试使用 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);
    }
    }
}
4

1 回答 1

1

看起来clickBt是未定义的。创建clickBt函数,你应该是金子!

于 2013-04-10T05:00:35.697 回答