Actionscript 3 AS3-较小的platformer类绑定错误

Actionscript 3 AS3-较小的platformer类绑定错误,actionscript-3,flash,class,error-handling,flash-cs5,Actionscript 3,Flash,Class,Error Handling,Flash Cs5,我的代码有一个小问题。我想链接所有三个类来制作一个简单的平台。代码如下: 数组类: package { import flash.display.*; public dynamic class setupStage extends Thiny { var mapWid = 24; var mapHei = 40; var tileSide = 10; var totalTiles = mapWid * mapHei; var cell:tile=new

我的代码有一个小问题。我想链接所有三个类来制作一个简单的平台。代码如下:

数组类:

package 
{
import flash.display.*;
public dynamic class setupStage extends Thiny
{
    var mapWid = 24;
    var mapHei = 40;
    var tileSide = 10;
    var totalTiles = mapWid * mapHei;
    var cell:tile=new tile();

    var firstStage:Array=[
      /*1*/[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
      /*2*/[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1]
      /*3*/[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1]
      /*4*/[1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1]
      /*5*/[1,0,0,0,1,0,0,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,0,1]
      /*6*/[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
      /*7*/[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
      /*8*/[1,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1]
      /*9*/[1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,1]
     /*10*/[1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1]
     /*11*/[1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1]
     /*12*/[1,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,1]
     /*31*/[1,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,0,0,0,0,1]
     /*32*/[1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1]
     /*33*/[1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1]
     /*34*/[1,0,0,0,0,0,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1]
     /*35*/[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
     /*36*/[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
     /*37*/[1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
     /*38*/[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
     /*39*/[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
     /*40*/[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
      ];
    function setupStage()
    {
        trace("access granted");
    }
    function drawMap():void
    {
        for (var i:int=0; i<mapWid; i++)
        {
            for (var u:int=0; u<mapHei; u++)
            {
                cell.gotoAndStop(firstStage[i][u]+1);
                cell.x = tileSide * i;
                cell.y = tileSide * u;
                with (stage)
                {
                    stage.addChild(cell);
                }
            }
        }
    }
}
}
主fla文件:

stop();
import flash.events.Event;
import flash.display.DisplayObject;
import flash.utils.*;
import flash.events.*;
import flash.sampler.StackFrame;

stage.addEventListener(Event.ENTER_FRAME,initialize);

function initialize(main_event:Event):void{
        with(setupStage){drawMap();};
        with(JAJEBIE){wrzut();};
        stage.removeEventListener(Event.ENTER_FRAME,initialize);
}
我们尝试了很多方法,但编译器不断抛出错误,即使在我们设法删除了所有代码问题之后,主类似乎也不想修补所有问题。 任何帮助都将不胜感激!
谢谢

您需要每个类的
JAJEBIE
setupStage
都有一个实例,这样您就有了一个platformer级别和玩家的样本。您的代码表示
JAJEBIE
是一个静态类,因为它没有构造函数,所以您通过类名对其进行寻址是正确的-除非对
JAJEBIE
抛出错误5000,否则在这种情况下,您的代码是完全错误的

var jajebie:JAJEBIE;
function initialize(main_event:Event):void{
    jajebie=new JAJEBIE();
    addChild(jajebie);
    addChild(jajebie.granica);
    // while neither is added to stage, they 
    // cannot reach the stage! You have to point them to actual stage.
    jajebie.granica.drawMap(); // now, as we have stage access, draw the map
    jajebie.wrzut();
    stage.removeEventListener(Event.ENTER_FRAME,initialize);
}
另外,在整个
setupStage
中只有一个
单元格
实例,并且您反复尝试设置其坐标并将其放入stage。这种方法是错误的,因为您将在屏幕上看到一个
cell
实例,它将是右下角的一个。通过在内部循环中重新实例化您的
单元格
来修复此问题

函数drawMap():void { 对于(变量i:int=0;i
最后,您需要自己学习阅读和解释错误消息,这样才能理解Flash想要告诉您什么。例如,错误5000意味着您必须扩展给定的类(很可能是
MovieClip
)对于您的任何一个类,这可能会迫使您立即返工大部分代码。

您得到的错误是什么?这些代码引用的是哪些代码行?
var jajebie:JAJEBIE;
function initialize(main_event:Event):void{
    jajebie=new JAJEBIE();
    addChild(jajebie);
    addChild(jajebie.granica);
    // while neither is added to stage, they 
    // cannot reach the stage! You have to point them to actual stage.
    jajebie.granica.drawMap(); // now, as we have stage access, draw the map
    jajebie.wrzut();
    stage.removeEventListener(Event.ENTER_FRAME,initialize);
}