• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Error message: 1021: Duplicate function definition.

New Here ,
Aug 30, 2011 Aug 30, 2011

Copy link to clipboard

Copied

Hi All,

First let me start by saying that I know next to nothing about Flash.  I have inherited a website maintenance project that has a Flash rotating image banner.  I have managed to get the images to fade-in and fade-out correctly, but now I need to make these images clickable - linking images to pages in the website.  I have read many posts here and have reviewed the video tutorials.  I have been able to get the first image clickable using this AS3 action:

mars_btn.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent) :void {
        navigateToURL(new URLRequest("http://somewebsite/mars.php"));
        trace("I'm clicked");
}

However, when I attempt to make another image clickable by using a different instance of a button I get the error message:

1021: Duplicate function definition.

I have a separate instance of a button with this AS3 action:

jupiter_btn.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent) :void {
        navigateToURL(new URLRequest("http://somewebsite/jupiter.php"));
        trace("I'm clicked");
}

Obviously I'm not understanding how I'm supposed to do this so that I don't create a duplicate function definition.  Any help would be most appreciated.

TOPICS
ActionScript

Views

3.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Aug 30, 2011 Aug 30, 2011

if you know nothing about AS then the simplest way would just rename the handler methods to unique names

mars_btn.addEventListener(MouseEvent.CLICK, marsClickHandler);
function marsClickHandler(event:MouseEvent) :void {
      navigateToURL(new URLRequest("http://somewebsite/mars.php"));
      trace("I'm clicked");
}

jupiter_btn.addEventListener(MouseEvent.CLICK, jupiterClickHandler);
function jupiterClickHandler(event:MouseEvent) :void {
      navigateToURL(new URLRequest("http://somewebsite/jupiter.ph

...

Votes

Translate

Translate
Guest
Aug 30, 2011 Aug 30, 2011

Copy link to clipboard

Copied

if you know nothing about AS then the simplest way would just rename the handler methods to unique names

mars_btn.addEventListener(MouseEvent.CLICK, marsClickHandler);
function marsClickHandler(event:MouseEvent) :void {
      navigateToURL(new URLRequest("http://somewebsite/mars.php"));
      trace("I'm clicked");
}

jupiter_btn.addEventListener(MouseEvent.CLICK, jupiterClickHandler);
function jupiterClickHandler(event:MouseEvent) :void {
      navigateToURL(new URLRequest("http://somewebsite/jupiter.php"));
      trace("I'm clicked");
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 30, 2011 Aug 30, 2011

Copy link to clipboard

Copied

Wow, thanks for the quick help!  It works great now.  Many thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 08, 2013 Apr 08, 2013

Copy link to clipboard

Copied

LATEST

excuse me , I have a question i hope that you help .. ( im new in here )

we were asked to create an interactive application on flash in two languages..

so i created two different fla files same exact codings ... i was wondering how can i combine them so the viewer can be able to choose the language from a button ?

when i try to combine them i get lots of errors of duplications in the actionscript

PS : MY MAIN PAGE INCLUDES A CAROUSEL with images ..

I was thinking of saving one of the fla  as a movie and then add it some how to the second fla and combine it with a button but i can't figure it how..

i hope i was clear enough.. but is there any possibility to help me please ?!

when i tend to change names or something it creates error.. ( IM NOT A PRO IN AS3 ) and when i dublicate the scenes it give duplication errors.. WHAT IS THE SOLUTION ??

this is the code of the actionscript in the main page.. ( the carousel's code i took from someone ) and i used it on my project

import com.ccanvas.carousel.*;


var centerX:Number = stage.stageWidth/4;
var centerY:Number = stage.stageHeight/4;
var carc:Carousel = new Carousel(centerX, centerY, 256, 75, "icons.xml");
carc.addTooltip(new tooltip); // use 'tooltip' movieclip for item tooltip
addChild(carc); // add carousel to stage

function down(event:MouseEvent):void {
trace(event.currentTarget.toolText); // simple click interaction
}

function destroyCarousel(event:MouseEvent):void {
carc.destroy(); // remove all item in carousel as well as tooltip
}

function removeNextItem(event:MouseEvent):void {
if(carc.numOfItems > 2) {
  carc.removeItem(2); // remove the item next to the remove item icon
}
}
create.addEventListener("mouseDown", createCarousel);

function createCarousel(event:MouseEvent):void {
if(carc.CREATED == false) {
  // recreate the carousel
  carc = new Carousel(centerX, centerY, 256, 75, "icons.xml");
  carc.addTooltip(new tooltip);
  addChild(carc);
}
}/* Click to Go to Scene and Play
Clicking on the specified symbol instance plays the movie from the specified scene and frame.

Instructions:
1. Replace "Scene 3" with the name of the scene you would like play.
2. Replace 1 with the frame number you would like the movie to play from in the specified scene.
*/

Tools_button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene);

function fl_ClickToGoToScene(event:MouseEvent):void
{
MovieClip(this.root).gotoAndPlay(1, "Toolse");
}/* Click to Go to Scene and Play
Clicking on the specified symbol instance plays the movie from the specified scene and frame.

Instructions:
1. Replace "Scene 3" with the name of the scene you would like play.
2. Replace 1 with the frame number you would like the movie to play from in the specified scene.
*/

games_button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToGames);

function fl_ClickToGoToGames(event:MouseEvent):void
{
MovieClip(this.root).gotoAndPlay(1, "Gamese");
}/* Click to Go to Scene and Play
Clicking on the specified symbol instance plays the movie from the specified scene and frame.

Instructions:
1. Replace "Scene 3" with the name of the scene you would like play.
2. Replace 1 with the frame number you would like the movie to play from in the specified scene.
*/

Identity_button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToIdentity);

function fl_ClickToGoToIdentity(event:MouseEvent):void
{
MovieClip(this.root).gotoAndPlay(1, "Identitye");
}/* Click to Go to Scene and Play
Clicking on the specified symbol instance plays the movie from the specified scene and frame.

Instructions:
1. Replace "Scene 3" with the name of the scene you would like play.
2. Replace 1 with the frame number you would like the movie to play from in the specified scene.
*/

Reviews_button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_13);

function fl_ClickToGoToScene_13(event:MouseEvent):void
{
MovieClip(this.root).gotoAndPlay(1, "Reviewse");
}/* Click to Go to Scene and Play
Clicking on the specified symbol instance plays the movie from the specified scene and frame.

Instructions:
1. Replace "Scene 3" with the name of the scene you would like play.
2. Replace 1 with the frame number you would like the movie to play from in the specified scene.
*/

Facts_button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_20);

function fl_ClickToGoToScene_20(event:MouseEvent):void
{
MovieClip(this.root).gotoAndPlay(1, "Factse");
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines