Actionscript 3 错误#1063:com.flashden::MenuItem()上的参数计数不匹配。预期为1,得到0
我正在使用嵌入在swf中的以下脚本创建一个新站点。但我在所有页面上都不断遇到这个错误:错误#1063:com.flashden::MenuItem()上的参数计数不匹配。预期为1,得到0Actionscript 3 错误#1063:com.flashden::MenuItem()上的参数计数不匹配。预期为1,得到0,actionscript-3,firefox,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.
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);
}
}
}
错误代码意味着您在某个地方实例化了对象,但没有传递scope变量。这通常是通过在stage上添加而不是通过编程实现的。检查代码,确保没有调用“new menuitem()”whthout var。如果要添加到stage,请考虑使用setscope函数 --编辑-- 如果您试图以编程方式执行此操作,请从后台删除所有元素,然后初始化并将其添加到后台,如下所示:
var menu = new MenuItem(this);
addChild(menu);
相反,如果您希望实现此功能以直接添加到阶段,请从括号中删除范围:
public function MenuItem()
删除此行:
this.scope = scope;
然后添加一个如下所示的函数:
public function setScope(scope){
this.scope = scope;
}
然后在应用程序的代码开始处调用object函数(imusingmenu,但将其重命名以适合stage上设置的对象实例名称):
@苏珊娜:如果你在这里发帖,人们通常会理解你需要帮助。添加帮助!问题的开头会分散你的注意力。建议你尽量缩短主题,这样在该领域有专长的人一眼就能知道你在问什么。@Suzanne:如果你的主题中的文字比你的文章正文(减去代码)多,然后你一定要用几句话概括主题,并在问题的正文中解释。@Suzanne:请在编辑器中选择代码,然后键入Control-K或单击带有0和1的按钮,以正确设置代码的格式。对不起,我是这个网站的新手。我是从一位经常使用它的朋友那里被推荐到这里的。我昨天写了同样的帖子(misnus the help),但没有收到回复。如何编辑帖子?上面说约翰你编辑了它。我真的不知道如何解决这个问题。我编辑了一个现有的脚本。我更新了帖子,加入了代码示例,以此为基础,如果你有问题,请告诉我。我仍然有问题。它给了我编译器正在读取的其他错误。我已经包括了一个链接到我的文件,如果你能看看,我会通知它。脚本文件位于dev\com\flashden中,我感谢您迄今为止的所有帮助。请随意删除错误,这些文件将以可读的形式显示在我的计算机上(可能是不同的flash版本)。最好的学习方式是做!
menu.setScope(this);