I doing a catching game for my assignment
Greeny1, Greeny 2, is object which dropping down
and i want they to play their own different animation(different movie clip) when hit the catcher.
my part of code is like…
var myArrayGreeny1:Array = new Array();
var myArrayGreeny2:Array = new Array();
//Greeny1
var myTimer1:Timer = new Timer(1000);
myTimer1.addEventListener(TimerEvent.TIMER, spawnGreeny1);
myTimer1.start();
function spawnGreeny1(e:TimerEvent)
{
var Greeny1C:Greeny1 = new Greeny1();
addChild(Greeny1C);
myArrayGreeny1.push(Greeny1C);
}
//Greeny2
var myTimer2:Timer = new Timer(2000);
myTimer2.addEventListener(TimerEvent.TIMER, spawnGreeny2);
myTimer2.start();
function spawnGreeny2(e:TimerEvent)
{
var Greeny2C:Greeny2 = new Greeny2();
addChild(Greeny2C);
myArrayGreeny2.push(Greeny2C);
}
stage.addEventListener(Event.ENTER_FRAME, startGame);
function startGame(e:Event)
{
//array Greeny1
for(var i=0; i < myArrayGreeny1.length; i++)
{
if(catcher.hitTestObject(myArrayGreeny1*))
{
var xplodeG1:Greeny1Animation = new Greeny1Animation();
addChild(xplodeG1);
xplodeG1.x = myArrayGreeny1*.x;
xplodeG1.y = myArrayGreeny1*.y;
xplodeG1.gotoAndPlay(2);
removeChild(myArrayGreeny1*);
myArrayGreeny1.splice(i, 1);
}
else if(beam.hitTestObject(myArrayGreeny1*))
{
removeChild(myArrayGreeny1*);
myArrayGreeny1.splice(i, 1);
}
}
//array Greeny2
for(var i=0; i < myArrayGreeny2.length; i++)
{
if(catcher.hitTestObject(myArrayGreeny2*))
{
var xplodeG2:Greeny2Animation = new Greeny2Animation();
addChild(xplodeG2);
xplodeG2.x = myArrayGreeny2*.x;
xplodeG2.y = myArrayGreeny2*.y;
xplodeG2.gotoAndPlay(2);
removeChild(myArrayGreeny2*);
myArrayGreeny2.splice(i, 1);
}
else if(beam.hitTestObject(myArrayGreeny2*))
{
removeChild(myArrayGreeny2*);
myArrayGreeny2.splice(i, 1);
}
}
}
and it showed duplicate variable definition on these lines:
for(var i=0; i < myArrayGreenyX.length; i++)
may someone help me on this code?
i am quite not familiar with flash TT