开发者

Error #1063: Argument count mismatch on com.flashden::MenuItem(). Expected 1, got 0

开发者 https://www.devze.com 2022-12-26 01:44 出处:网络
I\'m creating a new site using the below script embedded in my swf.But I keep getting this error on all the pages:Error #1063: Argument count mismatch on com.flashden::MenuItem(). Expected 1, got 0.

I'm creating a new site using the below script embedded in my swf. But I keep getting this error on all the pages: Error #1063: Argument count mismatch on com.flashden::MenuItem(). Expected 1, got 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 {
            //trac开发者_JS百科e("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);
        }     

 }
}


the error code means that somewhere you are instancing the object without passing the scope var. This is often through adding on stage rather than programatically. Check through the code and make sure you have no calls for 'new menuitem()' whthout var. Think about making a setscope function instead if you are adding to stage.

--edit--

if you are trying to do this programatically remove all elements of this from the stage and then initialise and add it to the stage like so:

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

if instead you would rather implement this to add directly to stage, remove scope from the brackets:

public function MenuItem()

remove this line:

this.scope = scope;

then add a function that looks like this:

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

then in the start of code in your application call the object function (im using menu, but rename this to fit the instance name of the object as set on the stage):

menu.setScope(this);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号