Skip navigation
TimsterVideo
Currently Being Moderated

Please check my code for calling 8 functions sequentially with one button

Aug 18, 2012 2:46 PM

Does this code look good for calling functions Func1  thru  Func8 every time  next_btn is clicked?

 

I get the following error:    Argument count mismatch on FWA_fla::MainTimeline/nextReg(). Expected 0, got 1.

 

My research tells me its most likely bad syntax. Do I need "Private" function? Thanks so much, I'm lost !!!

 

var counter:Number = 0;

 

this.next1_btn.addEventListener (MouseEvent.CLICK, nextFunc);

 

function nextFunc(event:MouseEvent) : void

{

    if (counter == 9) {

                                (counter == 0);

                }

                counter++;

                trace(counter)

    this["Func"+counter]();

}

 

 

//reg1 thru reg8 are defined below

function Func1 (event:MouseEvent) : void

{

do some thing

}

 

function Func1 (event:MouseEvent) : void

{

do some thing

}

 

// etc.

 
Replies
  • Currently Being Moderated
    Aug 18, 2012 3:27 PM   in reply to TimsterVideo

    No the code you show will not work.  You cannot have functions with the same name. Also, the errror is indicating a problem with a function named nextReg.  You do not show any function by that name.  If you are programming in the timeline you do not want to use private/public/etc...

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 18, 2012 6:07 PM   in reply to TimsterVideo

    Seeing as how you seem to be unable to show actual code/error messages, the best I can offer is... the errror is indicating that you do not specify the argument that you show in the code you posted for the nextFunc function

     

    Your other functions you show having an argument but you do not send one to them.

     

    function nextFunc(event:MouseEvent) : void // this line requires the "event.MouseEvent"

     

    function Func1 (event:MouseEvent) : void // these lines should not have "event.MouseEvent"

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 19, 2012 8:21 AM   in reply to TimsterVideo

    This should work:

     

     

    next1_btn.addEventListener(MouseEvent.CLICK, nextFunc);
     
    var counter:int = 0;
     
    function nextFunc(e:MouseEvent):void
    {
           this["func" + counter % 9]();
          counter++;
    }
     
    function func1():void
    {
          trace("func 1 called");
    }
     
    function func2():void
    {
          trace("func 2 called");
    }
    // etc...
     
    
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points