Function Actionscript-函数不是有效的类型

Function Actionscript-函数不是有效的类型,function,actionscript,types,return,Function,Actionscript,Types,Return,昨天这里有人帮我解决了一个问题。我在测试之前就接受了答案,现在遇到了问题 我正在做的是我有一个飞机mc和一个板条箱mc。飞机沿着y轴飞行,我试图让板条箱mc沿着飞机的路径随机落下。飞机在y轴上的每一点上不断地投放板条箱 我用来移动板/放下板条箱的代码是: function makePlane():void { var chance:Number = Math.floor(Math.random() * 60); if (chance <= 1) {

昨天这里有人帮我解决了一个问题。我在测试之前就接受了答案,现在遇到了问题

我正在做的是我有一个飞机mc和一个板条箱mc。飞机沿着y轴飞行,我试图让板条箱mc沿着飞机的路径随机落下。飞机在y轴上的每一点上不断地投放板条箱

我用来移动板/放下板条箱的代码是:

function makePlane():void
{
    var chance:Number = Math.floor(Math.random() * 60);
    if (chance <= 1)
    {
        trace(chance);

        var tempPlane:MovieClip;
        //Make sure a Library item linkage is set to Plane...
        tempPlane = new Airplane();
        tempPlane.planeSpeed = 10;
        tempPlane.x = Math.round(Math.random() * 1000);
        tempPlane.y = Math.round(Math.random() * -1000);
        addChild(tempPlane);
        trace("Made Plane!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
        planes.push(tempPlane);
    }
}

function movePlane():void
{

    var tempX:Number;
    var tempCrate:MovieClip;
    var tempPlane:MovieClip;

    for (var j:int =planes.length-1; j>=0; j--)
    {
        tempPlane = planes[j];
        tempPlane.y +=  tempPlane.planeSpeed;
        tempCrate = new Crate();
        tempCrate.y = tempPlane.y;
        tempCrate.x = tempPlane.x;
        addChild(tempCrate);
        crates.push(tempCrate);
    }
}
函数makePlane():void
{
var chance:Number=Math.floor(Math.random()*60);
如果(机会=0;j--)
{
templane=平面[j];
templane.y+=templane.planeSpeed;
临时板条箱=新板条箱();
tempCrate.y=templane.y;
tempCrate.x=templane.x;
addChild(临时板条箱);
板条箱。推(临时板条箱);
}
}
有人给我的代码是:只扔1个板条箱,而不是多个板条箱:

  function addRandomCreation():void{
    var animationTime:Number = 5000; //The time the planes will be animating in ms 

    for(var i:int = 0; i < planes.length; i++){
        var planeTimer:Timer = new Timer(Math.round(animationTime * Math.random()));
        planeTimer.addEventListener(TimerEvent.TIMER, timerComplete(i));
        planeTimer.start();
    }
}

function timerComplete(planeID:int):function{
    return function(event:TimerEvent):void{
        event.target.stop();
        event.target.removeEventListener(event.type, arguments.callee);

        var tempCrate:MovieClip = new Crate();
        tempY = Math.round(Math.random() * planes[planeID].y);
        tempCrate.y = tempY;
        tempCrate.x = planes[planeID].x;
        addChild(tempCrate);        
    }
}
函数addRandomCreation():void{
var animationTime:Number=5000;//平面将设置动画的时间(毫秒)
对于(变量i:int=0;i

当我尝试使用这段代码时,我得到一个错误“函数不是一个类型”。我以前从未见过函数用作返回类型。有人能帮我吗?

返回类型
function
应该大写:
function
。timerComplete函数在闭包中锁定planeID,以便可以从事件处理程序(timerComplete返回的函数)访问它