错误#1063:com.flashden :: MenuItem()上的参数计数不匹配。预计1,得0

时间:2010-04-09 20:29:50

标签: actionscript-3 firefox

我正在使用swf中嵌入的以下脚本创建一个新站点。但是我一直在所有页面上都出现此错误:错误#1063:com.flashden :: MenuItem()上的参数计数不匹配。预计1,得到0。

package com.flashden
{
 import flash.display.MovieClip;
 import flash.text.*;
 import flash.events.MouseEvent;
 import flash.events.*;
    import flash.net.URLRequest;
 import flash.display.Loader;

 public class MenuItem extends MovieClip
 {
  private var scope;
  public var closedX;    :Number

  public static const OPEN_MENU = "openMenu";

  public function MenuItem(scope)
  {
   // set scope to talk back to -------------------------------//
   this.scope = scope;

   // disable all items not to be clickable -------------------//
   txt_label.mouseEnabled = false;
   menuItemShine.mouseEnabled = false;
   menuItemArrow.mouseEnabled = false;

   // make background clip the item to be clicked (button) ----//
   menuItemBG.buttonMode = true;

   // add click event listener to the header background -------//
   menuItemBG.addEventListener(MouseEvent.CLICK, clickHandler);
  }

  private function clickHandler (e:MouseEvent)
  {
   scope.openMenuItem(this);
  }

  public function loadContent (contentURL:String)
  {
   var loader:Loader = new Loader();
            configureListeners(loader.contentLoaderInfo);

            var request:URLRequest = new URLRequest(contentURL);
            loader.load(request);

   // place x position of content at the bottom of the header so the top is not cut off ----//
   loader.x = 30;

   // we add the content at level 1, because the background clip is at level 0 ----//
            addChildAt(loader, 1);
  }


  private function configureListeners(dispatcher:IEventDispatcher):void {
            dispatcher.addEventListener(Event.COMPLETE, completeHandler);
            dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
            dispatcher.addEventListener(Event.INIT, initHandler);
            dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
            dispatcher.addEventListener(Event.OPEN, openHandler);
            dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
            dispatcher.addEventListener(Event.UNLOAD, unLoadHandler);
        }

        private function completeHandler(event:Event):void {
            //trace("completeHandler: " + event);
   // remove loader animation ----------------//
   removeChild(getChildByName("mc_preloader"));
        }

        private function httpStatusHandler(event:HTTPStatusEvent):void {
           // trace("httpStatusHandler: " + event);
        }

        private function initHandler(event:Event):void {
            //trace("initHandler: " + event);
        }

        private function ioErrorHandler(event:IOErrorEvent):void {
            //trace("ioErrorHandler: " + event);
        }

        private function openHandler(event:Event):void {
            //trace("openHandler: " + event);
        }

        private function progressHandler(event:ProgressEvent):void {
            //trace("progressHandler: bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
        }

        private function unLoadHandler(event:Event):void {
            //trace("unLoadHandler: " + event);
        }     

 }
}

1 个答案:

答案 0 :(得分:1)

错误代码意味着您正在实例化对象而不传递范围var。这通常是通过在舞台上而不是以编程方式添加。检查代码,确保没有调用'new menuitem()'。如果要添加到舞台,请考虑制作一个setcope函数。

- 编辑 -

如果您尝试以编程方式从舞台中删除此内容的所有元素,然后初始化并将其添加到舞台中,如下所示:

var menu = new MenuItem(this);
addChild(menu);

如果您宁愿实现此项以直接添加到舞台,请从括号中删除范围:

public function MenuItem()

删除此行:

this.scope = scope;

然后添加一个如下所示的函数:

public function setScope(scope){
    this.scope = scope;
}

然后在应用程序的代码开始时调用对象函数(使用菜单,但重命名为适合在舞台上设置的对象的实例名称):

menu.setScope(this);