views:

140

answers:

1

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 {
            //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  A: 

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);
shortstick
Im not really sure how to resolve this. Im edited a existing script.
Suzanne
ive updated the post to include code examples, use this as a base let me know if you have problems.
shortstick
Im still having trouble. Its giving me other errors that the compiler is reading off. Ive included a link to my files http://www.yourmarketingwiz.com/scripfiles/test2.zip If you can take a look at it I would appriecate it. The script files are in dev\com\flashden I appricate all your help so far.
Suzanne
feel free to drop the errors, the files arnt in a readable form for my computer (probably different flash version). best way of learning is by doing!
shortstick
got it to work!! thanks for your help!!
Suzanne