【问题标题】:Error #1063: Argument count mismatch on com.flashden::MenuItem(). Expected 1, got 0错误 #1063:com.flashden::MenuItem() 上的参数计数不匹配。预期 1,得到 0
【发布时间】:2010-04-11 15:58:22
【问题描述】:

我正在使用嵌入在我的 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);
        }     

 }
}

【问题讨论】:

  • @Suzanne:如果您在这里发帖,人们通常会理解您需要帮助。添加帮助!问题的开头会分散您所问的内容。建议您尝试缩短主题,以便具有该领域专业知识的人一眼就知道您要问什么。
  • @Suzanne:如果您的主题中的文字多于帖子正文(减去代码),那么您绝对应该将主题总结为几句话并解释在您的问题正文中
  • @Suzanne:请通过在编辑器中选择您的代码来正确格式化您的代码,然后输入 Control-K 或单击带有 0 和 1 的按钮。
  • 对不起,我是这个网站的新手。一位经常使用它的朋友向我推荐了这里。我昨天写了同样的帖子(忽略了帮助)并且没有收到任何答案。如何编辑帖子?它说约翰是你编辑的。

标签: actionscript-3 firefox


【解决方案1】:

错误代码意味着您在某个地方实例化对象而没有传递范围 var。这通常是通过在舞台上添加而不是通过程序添加。检查代码并确保在没有 var 的情况下没有调用“new menuitem()”。如果您要添加到舞台,请考虑制作一个 setscope 函数。

--编辑--

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

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

如果您宁愿实现这一点以直接添加到阶段,请从括号中删除范围:

public function MenuItem()

删除这一行:

this.scope = scope;

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

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

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

menu.setScope(this);

【讨论】:

  • 我不确定如何解决这个问题。我编辑了一个现有的脚本。
  • 我更新了帖子以包含代码示例,以此为基础,如果您有问题,请告诉我。
  • 我还是有问题。它给了我编译器正在读取的其他错误。我已经包含了一个指向我的文件的链接yourmarketingwiz.com/scripfiles/test2.zip 如果你可以看看它,我会appriecate它。脚本文件位于 dev\com\flashden 中,到目前为止,我感谢您提供的所有帮助。
  • 随意删除错误,文件以我的计算机可读的形式(可能不同的闪存版本)。最好的学习方式就是边做边做!
猜你喜欢
  • 2019-03-01
  • 2011-06-25
  • 2012-09-08
  • 1970-01-01
  • 1970-01-01
  • 2021-07-29
  • 2021-08-22
  • 2019-08-28
  • 1970-01-01
相关资源
最近更新 更多