As3 Error 1021 Duplicate Function Definition
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How to fix this duplicate function definition error? up vote 0 down vote favorite I am totally new at Flash CS6 Action script 3. I have to do an assignment of a scene that have to have mouse, keyboard, enter frame, and time events. Every time I test the movie out, I keep on getting an error that says, 'duplicate function definition' about the 'enter frame event' and 'timer event' functions'. I have tried to rename the functions, but it didn't work. Is there another solution to this? Also, could you please show some examples? Thanks! QuestionMC.addEventListener(MouseEvent.CLICK, onClick); QuestionMC.addEventListener(MouseEvent.ROLL_OVER, questionOver); QuestionMC.addEventListener(MouseEvent.ROLL_OUT, questionOut); function questionOver(event:MouseEvent):void { event.target.alpha = .5; } function questionOut(event:MouseEvent):void { event.target.alpha = 1; } function onClick(event:MouseEvent):void { //trace("click!!!"); event.target.y -= 15; event.target.rotation += 45; } QuestionMC.buttonMode = true; stage.addEventListener(KeyboardEvent.KEY_DOWN, jump); stage.addEventListener(KeyboardEvent.KEY_UP, land); function jump (event:KeyboardEvent): void { trace(event.keyCode); YoshiMC.y -= 50 stage.removeEventListener(KeyboardEvent.KEY_DOWN, jump); stage.addEventListener(Event.ENTER_FRAME, flip); } function land (event:KeyboardEvent): void { YoshiMC.y += 50 stage.addEventListener(KeyboardEvent.KEY_DOWN, jump); stage.removeEventListener(Event.ENTER_FRAME, flip); } function flip(event:Event):void { YoshiMC.rotation += 45; YoshiMC.x += 20; } var jumpTimer:Timer = new Timer(5000,1); jumpTimer.addEventListener(TimeEvent.TIMER, jump); function jump (event:TimerEvent):void { planteaterMC.play(); } jumpTimer.start(); var link:URLRequest = new URLRequest(""); buttongoeshere.addEventListener(MouseEvent.CLICK, clickHere); function clickHere(event:MouseEvent):void { navigateToURL(link); } buttongoeshere.buttonMode = true; actionscript-3 encoding flash-cs6 share|improve this question asked Mar 1 '14 at 20:20 user3369167 111
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers http://stackoverflow.com/questions/22119838/how-to-fix-this-duplicate-function-definition-error or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it http://stackoverflow.com/questions/16000556/1021-duplicate-function-definition-in-my-action-script only takes a minute: Sign up 1021: Duplicate function definition in my action Script up vote 1 down vote favorite This is a follow up to my previous question (Problems Scripting Multiple Buttons(nearly identical) in a single Action Script) I am making an interactive flash Project...It has has 17 Separate scenes ... Intro Scene "Main_ Sequence" 15 Individually title song pages .... Where my first issue is the "main sequence" has 15 Buttons and I need to link them to the 15 separate scenes ...I am using the following code... TD_g.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); s_g.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); ats_g.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); iyk_g.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); hms_g.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); tf_g.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); hd_g.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); ld_g.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); ll_g.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); ts_g.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); ipsy_g.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); ysm_g.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); ihm_g.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); iss_g.addEventListener(MouseEvent.MOUSE_DOWN, mo
to the user with is not always the easiest to understand. A typical ActionScript error in Flash Professional will look something like http://blog.easelsolutions.com/2010/12/fixing-actionscript-errors/ this: Implicit coercion? It's pretty obvious why people struggle learning ActionScript. There are essentially two parts to an ActionScript Error: The location (on the left) and the description (on the right). Double-clicking on an error takes you to the line the error occurred (most of the time). Occasionally it will take you to a different location as3 error unrelated to the error. Let's look at some of the most common error message, what they mean, and how to fix them. If you're interested, a list of all the possible ActionScript errors can be found in the help files here. Also, here's a nice search site where you can type in the error code as3 error 1021 and see a description. 1021: Duplicate function definition. This one is pretty easy. It's saying you have the same function declared two times in your code (as pictured below). function doSomething():void{ } function doSomething():void{ } Solution: Delete or rename one of the functions. 1046 Type was not found or was not a compile-time constant: [Something]. This error shows up whenever you have a variable defined in your code and Flash doesn't know the type (what comes after the colon). //"Number" is spelled wrong and would cause an error var totalScore:Nummber; //Same error occurs with this line, however "Tween" is spelled //correctly. In this case you need an import statement var animation:Tween; Solutions: Fix the spelling or add an import statement 1051 Return value must be undefined. You have a function with a return type of "void" that is returning a value. function doSomething():void{ var total:Number = 10; return total; } Solutions: Either change the void to match the type of what you'r