user1306971
user1306971

Reputation: 1

AS3 - 3596: Duplicate variable definition

Okay, I've been working all day on this error and had no luck, I searched everywhere, andall questions hee for an answer, got a couple of ones but none worked out for me. The code used to work fine but once I modified a text and a couple of lines from the script, I started having this "Duplicate variable definition." with a code totally unrelated with what I edited (I only edited the music player script that I was having problems with). The code I'm having problem goes like this:

     var mufl:* = size + 0.2;
     size = size + 0.2;
     mufl0 = Math.sin(mufl) * 8 + 4;
  1  var mufl:* = red + RED_STEP;
     red = red + RED_STEP;
  2  var mufl:* = blue + BLUE_STEP;
     blue = blue + BLUE_STEP;
  3  var mufl:* = green + GREEN_STEP;
     green = green + GREEN_STEP;

Math functions:

 mufl5 = Math.sin(mufl) * 128 + 127 << 16 | Math.sin(mufl) * 128 + 127 << 8 | Math.sin(mufl) * 128 + 127;
        list.push(new SpiritPlayer(px, py, mufl2, mufl3, mufl4, mufl5));

I keep getting the error on the lins 1,2 and 3 (where the var is)

The code uses some Math functions,etc... The main purpose of this code is to create a colorful waves (much like the the old Media Player 11 "Alchemy" visualization), but would change color and shapes everytime the user uses his mouse. The final purpose of this is to make a colorful, interactive music player for a online radio we are trying to build.

Thanks in advance.

Upvotes: 0

Views: 935

Answers (1)

FlavorScape
FlavorScape

Reputation: 14299

Well, you're defining it multiple times in the same scope. Declare it once in your scope and THEN assign it.

  var mufl:*;
  mufl = size + 0.2;
  size = size + 0.2;
  mufl0 = Math.sin(mufl) * 8 + 4;
  mufl = red + RED_STEP;
  red = red + RED_STEP;
  mufl = blue + BLUE_STEP;
  blue = blue + BLUE_STEP;
  mufl = green + GREEN_STEP;
  green = green + GREEN_STEP;

Upvotes: 1

Related Questions