Error 1151: a conflict exists with definition enlargeball (also enlarging)

93 Views Asked by At

Ok keep in mind I am a complete noob and phraseology often baffles me. And I might use it wrong too (just to keep in mind)

So i have error 1151, and I have read many other posts and looked into Adobe and basically it says "You cannot declare more than one variable with the same identifier name within the same scope unless all such variables are declared to be of the same type". I'm obviously not understanding what "same type" is. What I thought was, for example

var myvariable:int = 3

that the "type" was "int" (integer). My variable is suposed to create two tween effects for two objects, the whole thing goes:


var ballpopinstance:ballpopclass = new ballpopclass();
addChild(ballpopinstance);
ballpopinstance.x = randNum1;
ballpopinstance.y = 0;
var enlargeball:Tween = new Tween(ballpopinstance, "y", Strong.easeOut, parent.y, parent.y+50, 1, true);
var enlargeball:Tween = new Tween(ballpopinstance, "alpha", Strong.easeOut, parent.y, parent.y+50, 1, true);

var ringpopinstance:ringpopclass = new ringpopclass();
addChild(ringinstance);
ringpopinstance.x = randNum2;
ringpopinstance.y = 0;
var enlargering:Tween = new Tween(ringpopinstance, "y", Strong.easeOut, parent.y, parent.y+50, 1, true);
var enlargering:Tween = new Tween(ringpopinstance, "alpha", Strong.easeOut, parent.y, parent.y+50, 1, true);
};

with the errors on line 16 and 23 (I'm reposting lines 15, 16 from above because I assume it's because of line 15 that 16 is in error, also I am not posting 23 because line 23 error is the same issue as 16)

15 var enlargeball:Tween = new Tween(ballpopinstance, "y", Strong.easeOut, parent.y, parent.y+50, 1, true);

16 var enlargeball:Tween = new Tween(ballpopinstance, "alpha", Strong.easeOut, parent.y, parent.y+50, 1, true);


However in my ignorance I would assume the type would be "Tween", therefore be the same type and therefore be allowed within the same scope. Also, the whole for loop is what I assume the "scope" is considered.

Any help would be appreciated and I dont mind a complete overhaul if it's inefficient or repetitive or whatever. I think I posted everything someone would need to address my question.

1

There are 1 best solutions below

0
helloflash On

"You cannot declare more than one variable with the same identifier name within the same scope" : true "...unless all such variables are declared to be of the same type" : false.

Then, this message of Flash compiler simply means that there is already a variable by the name 'enlargeball' (and another by the name 'enlargering') in your code. These variables are declared two times here. You have just to give them fifferent names :

var tweenOne:Tween = new Tween(/* ... */);
var tweenTwo:Tween = new Tween(/* ... */);

The compiler wouldn't make more difference if these variables were not of the same type :

// You shall have the same error message here:
var something:int = 12;
var something:String = "nothing";

But a local variable (declared in a function) will not generate this error :

var something:int = 12;

function test():void
{
    var something:String = "nothing"; // different scope
}