这个错误在哪里?

时间:2012-01-27 10:43:21

标签: actionscript-3

可能是因为我写了它,但是,错误在哪里?

function getTotalVideoFrame ():int {
    if (video.current > 0) {
        var frames:int = 0;
        for (i:int = 0; i < video.current; i ++) {
            frames += video.chapters[i].frames;
        }
        frames = frames + getCurrentVideoFrame ();
        return frames;
    }
    return getCurrentVideoFrame ();
}

错误:

Scene 1, Layer 'as3', Frame 1, Line 1051    1084: Syntax error: expecting in before colon.
Scene 1, Layer 'as3', Frame 1, Line 1051    1084: Syntax error: expecting rightbrace before rightparen.

如果我comment the for statement一切正常,我必须花时间看不到错误。

3 个答案:

答案 0 :(得分:2)

我认为您在var循环中遗漏了for

for (var i:int = 0; i < video.current; i ++)

答案 1 :(得分:0)

arghh !!找到了......

// the wrong for
for (i:int = 0; i < video.current; i ++) {
    frames += video.chapters[i].frames;
}

我忘了添加var关键字

// the right for
for (var i:int = 0; i < video.current; i ++) {
    frames += video.chapters[i].frames;
}

答案 2 :(得分:0)

function getTotalVideoFrame():int {
    if(video.current&gt; 0){
        var frames:int = 0;
         for(var i:int = 0; i&lt; video.current; i ++){
            frames + = video.chapters [i] .frames;
        }
        frames = frames + getCurrentVideoFrame();
        返回帧;
    }
    return getCurrentVideoFrame();
}