-2

この1つのエラーで大きな問題が発生しています

//Obligitory Stop
stop();

//Imports
import flash.events.Event;
import flash.events.KeyboardEvent;
import fl.motion.easing.Back;
import flash.events.MouseEvent;
import flash.accessibility.Accessibility;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.display.MovieClip;


//Variables
var bulletSpeed:uint = 20;
var scoreData:int;
var bullets:Array = new Array();
var killCounter:int;
var baddieCounter:int;
var currentLevel:int = 1;
var baddieDamage:int;
var energyCost:int;
var target:MovieClip;
var baddies:Array = new Array();
var timer:Timer = new Timer(1);
var baddieSpeed:int;
var score:int;
var levelKR:int;
var level1KR:int = 10;
var level2KR:int = 25;
var level3KR:int = 50;
var upPressed:Boolean = false;
var downPressed:Boolean = false;
var Baddie:MovieClip
var mySound:Sound = new ShootSFX(); 

//Level Atributes set
if (currentLevel == 1)
{
    baddieSpeed = 2;
    baddieDamage = 20;
    timer.delay = 4000;
    levelKR = level1KR;
    bulletSpeed = 10;
    energyCost = 50;
    var energyTimer:Timer = new Timer(50);
    var healthTimer:Timer = new Timer(1000);
}

//Event Listeners
stage.addEventListener(MouseEvent.MOUSE_DOWN, fireGun);
stage.addEventListener(Event.ENTER_FRAME, moveObjects);
timer.addEventListener(TimerEvent.TIMER, addBaddie);
rbDash.addEventListener(Event.ENTER_FRAME, fl_MoveInDirectionOfKey);
stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, fl_UnsetKeyPressed);

//Timers Start
timer.start();
energyTimer.start();
healthTimer.start();

//Initialize score
Score.text = String("Level "+currentLevel+" - begin!");

//load score data
score = scoreData;

//Checks Kill Counter
checkKillCounter();


//Shoot gun on space
function fireGun(evt:KeyboardEvent)
{
    if (evt.keyCode == Keyboard.SPACE)
    {
        bullet.x = rbDash.x;
        bullet.y = rbDash.y + 50;
        addChild(bullet);
        bullets.push(bullet);

    }

}

//Move Objects
function moveObjects(evt:Event):void
{
    moveBullets();
    moveBaddies();
}

//Move bullets
function moveBullets():void
{
    for (var i:int = 0; i < bullets.length; i++)
    {
        var dx = Math.cos(deg2rad(bullets[i].rotation)) * bulletSpeed;
        var dy = Math.sin(deg2rad(bullets[i].rotation)) * bulletSpeed;
        bullets[i].x +=  dx;
        bullets[i].y +=  dy;
        if (bullets[i].x <-bullets[i].width
        || bullets[i].x > stage.stageWidth + bullets[i].width
        || bullets[i].y < -bullets[i].width
        || bullets[i].y > stage.stageHeight + bullets[i].width)
        {
            removeChild(bullets[i]);
            bullets.splice(i, 1);
        }
    }
}

//Spawns Enemy
function addBaddie(evt:TimerEvent):void
{
    updateScore(25);
    var baddie:Baddie = new Baddie();
    var side:Number = Math.ceil(Math.random() * 4);
    if (side == 1)
    {
        baddie.x = Math.random() * stage.stageWidth;
        baddie.y =  -  baddie.height;
    }
    else if (side == 2)
    {
        baddie.x = stage.stageWidth + baddie.width;
        baddie.y = Math.random() * stage.stageHeight;
    }
    else if (side == 3)
    {
        baddie.x = Math.random() * stage.stageWidth;
        baddie.y = stage.stageHeight + baddie.height;
    }
    else if (side == 4)
    {
        baddie.x =  -  baddie.width;
        baddie.y = Math.random() * stage.stageHeight;
    }
    baddie.speed = baddieSpeed;
    addChild(baddie);
    baddies.push(baddie);
    baddieCounter +=  1;
    if (baddieCounter == levelKR)
    {
        timer.stop();
    }
}

//Moves Enemy
function moveBaddies():void
{
    for (var i:int = 0; i < baddies.length; i++)
    {
        var dx = Math.cos(deg2rad(baddies[i].angle)) * baddies[i].speed;
        var dy = Math.sin(deg2rad(baddies[i].angle)) * baddies[i].speed;
        baddies[i].x +=  dx;
        baddies[i].y +=  dy;
        if (baddies[i].hitTestPoint(rbDash.x,rbDash.y,true))
        {
            removeChild(baddies[i]);
            baddies.splice(i, 1);
            //HealthBar.gotoAndStop(HealthBar.currentFrame + baddieDamage);
            killCounter +=  1;
            checkKillCounter();
            //if (HealthBar.currentFrame == 100)
            {
                gotoAndStop(5);
            }
        }
        else
        {
            checkForHit(baddies[i]);
        }
    }
}


//Hit detection
function checkForHit(baddie:Baddie):void {//Level 1, Layer 'Actions', Frame 1, Line 166 1046: Type was not found or was not a compile-time constant: Baddie.
    for (var i:int = 0; i < bullets.length; i++)
    {
        if (baddie.hitTestPoint(bullets[i].x,bullets[i].y,true))
        {
            removeChild(baddie);
            removeChild(bullets[i]);
            baddies.splice(baddie.indexOf(baddie), 1);
            bullets.splice(bullets[i]);
            updateScore(100);
            killCounter +=  1;
            checkKillCounter();
        }
    }
}

//Updates score
function updateScore(points:int):void
{
    score +=  points;
    Score.text = String("Points: "+score);
}

//stops timers
function timerStop():void
{
    timer.stop();
    energyTimer.stop();
    healthTimer.stop();
}

//Y axis movement
//totaly not a code snippet
function fl_MoveInDirectionOfKey(event:Event)
{
    if (upPressed)
    {
        rbDash.y -=  5;
    }
    if (downPressed)
    {
        rbDash.y +=  5;
    }
}

function fl_SetKeyPressed(event:KeyboardEvent):void
{
    switch (event.keyCode)
    {
        case Keyboard.UP :
            {
                upPressed = true;
                break;

            };
        case Keyboard.DOWN :
            {
                downPressed = true;
                break;

        }
    }
};

function fl_UnsetKeyPressed(event:KeyboardEvent):void
{
    switch (event.keyCode)
    {
        case Keyboard.UP :
            {
                upPressed = false;
                break;

            };
        case Keyboard.DOWN :
            {
                downPressed = false;
                break;

        }

    }
};

//makes the deg2rad work for the bullets/enemy
function deg2rad(degree)
{
    return degree * (Math.PI / 180);//Had issues with "deg2rad" functions
}

//Removes listeners
function removeAllListeners():void
{
    stage.removeEventListener(MouseEvent.MOUSE_DOWN, fireGun);
    stage.removeEventListener(Event.ENTER_FRAME, moveObjects);
    timer.removeEventListener(TimerEvent.TIMER, addBaddie);
}

//Checks if level end
function checkKillCounter():void
{
    EnemiesLeft.text = ("Enemies Left: "+String(levelKR - killCounter));
    if (killCounter == levelKR)
    {
        shutdown();
        gotoAndStop(3);
    }
}

//Stops everything
function shutdown():void
{
    timerStop();
    removeAllListeners();
    removeChild(target);
}

Level 1, Layer 'Actions', Frame 1, Line 166 1046: Type was not found or was not a compile-time constant: Baddie.

ありがとう みんな 今日はこれを終わらせようとしている

4

2 に答える 2

1

Baddieデフォルトのパッケージに含まれるクラスですか? そうでない場合は、インポートする必要があります。

import packagename.Baddie;

がライブラリ シンボルの場合Baddieは、[ActionScript 用にエクスポート] をオンにして、リンケージ名が正しいことを確認してください。また、それがフレーム 1 にエクスポートされていること、または少なくともコードが存在するフレームの前またはフレームにエクスポートされていることを確認してください。

于 2013-06-06T02:33:25.717 に答える