0

当我调用一个方法时,我得到 1136 错误,它说我需要 1 个参数,但我没有请求任何参数:

function tutorial()
{
main.arcade.gotoAndStop(5);
gotoAndPlay(2);
Main();
}

这是我正在打电话的课程

package 
{

import flash.display.MovieClip;
import flash.events.Event;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;


public class Main extends MovieClip
{

    var temp:int;
    var temp2:int;
    var onLeft:Boolean = true;
    var coolDown:int;
    var distance:int;
    var p2h= new hitBar2();
    var p1h= new hitBar();
    var roy = new Roy();
    var shane = new Shane();

    public function Main(){
        combat(roy,shane);

    }

我对actionscript和一般编程很陌生,请帮忙!!!

4

1 回答 1

0

你不能像这样调用构造函数

Main();

尝试

var main:Main = new Main();

此外,如果 Main 类是您的应用程序主类(入口点),那么您可以执行以下操作。

package 
{
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.events.Event;
    import flash.events.KeyboardEvent;
    import flash.ui.Keyboard;

    public class Main extends MovieClip
    {
    var temp:int;
    var temp2:int;
    var onLeft:Boolean = true;
    var coolDown:int;
    var distance:int;
    var p2h= new hitBar2();
    var p1h= new hitBar();
    var roy = new Roy();
    var shane = new Shane();

    public function Main()
    {
        if (stage) init();
        else addEventListener(Event.ADDED_TO_STAGE, init);
    }

    private function init():void
    {
       removeEventListener(Event.ADDED_TO_STAGE,init);
       combat(roy,shane);
    }

    private function combat(roy:Roy,shane:Shane):void
    {

    }
}
于 2012-04-26T03:01:20.233 回答