1 Reply Latest reply on Nov 13, 2007 2:06 PM by Newsgroup_User

    Keep getting error: Duplic function detected

    TnaE
      I'm using this actionscript in AS3:

      about_bttn.addEventListener(MouseEvent.CLICK, onClick);

      function onClick(Event:MouseEvent):void {
      navigateToURL( new URLRequest(" http://www.tnae.net/aocwebpage_002.htm"), "_self");
      }


      and then this in the same frame on a different layer.

      lore_bttn.addEventListener(MouseEvent.CLICK, onClick);

      function onClick(Event:MouseEvent):void {
      navigateToURL( new URLRequest(" http://www.tnae.net/aocwebpage_003.htm"), "_self");
      }


      It works fine unless I try to make two buttons in the same flash document then it gives me duplicate function error. I am changing the name in the action script to the appropriate name for the 2nd button but I still get the error.

      If I want a flash menu with a list of buttons that all link to different webpages how do I do the action script for those buttons without getting a duplicate function error?

      Thanks.

      EDIT:

      Ok I found a solution to this. Here is what I had to change for this to work:

      lore_bttn.addEventListener(MouseEvent.CLICK, onClick);

      function onClick 2(Event:MouseEvent):void { <----That bold 2 right there is what had to be added to it.
      navigateToURL( new URLRequest(" http://www.tnae.net/aocwebpage_002.htm"), "_self");
      }
        • 1. Re: Keep getting error: Duplic function detected
          Level 7
          Hi --

          You need to create functions with different names for each buttons "onClick"
          event..


          skip_bttn.addEventListener(MouseEvent.CLICK, onSkipClick);

          another_bttn.addEventListener(MouseEvent.CLICK, onAnotherClick);

          function onSkipClick(Event:MouseEvent):void {
          navigateToURL( new
          URLRequest(" http://www.tnae.net/aocwebpage_002.htm"),"_self");
          }

          function onAnotherClick(Event:MouseEvent):void {
          navigateToURL( new URLRequest( http://www.domain.com),"_self");
          }



          Rich

          "TnaE" <webforumsuser@macromedia.com> wrote in message
          news:fh5q3b$4lj$1@forums.macromedia.com...
          > I'm using this actionscript in AS3:
          >
          > skip_bttn.addEventListener(MouseEvent.CLICK, onClick);
          >
          > function onClick(Event:MouseEvent):void {
          > navigateToURL( new URLRequest(" http://www.tnae.net/aocwebpage_002.htm"),
          > "_self");
          > }
          >
          >
          > It works fine unless I try to make two buttons in the same flash document
          > then
          > it gives me duplicate function error. I am changing the name in the action
          > script to the appropriate name for the 2nd button but I still get the
          > error.
          >
          > If I want a flash menu with a list of buttons that all link to different
          > webpages how do I do the action script for those buttons without getting a
          > duplicate function error?
          >
          > Thanks.
          >