Mohammed Omidvar
New Member
- Messages
- 1
- Likes
- 0
I try to make a game but I fail in one thing. my enemie has an explosion animation but it wont play
I marked the line red it always give me an error saying: enemies.gotoAndPlay(27); is not an function
where is my mistake? I deletet some of my code because the forum said its to long...lol
I marked the line red it always give me an error saying: enemies.gotoAndPlay(27); is not an function
where is my mistake? I deletet some of my code because the forum said its to long...lol
Code:
[COLOR=#0000FF][FONT=monospace]private[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]var[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] enemies=[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]Array[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace];[/FONT][/COLOR]
[COLOR=#0000FF][FONT=monospace]private[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]var[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] bullets:[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]Array[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace];[/FONT][/COLOR]
[COLOR=#0000FF][FONT=monospace]private[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]var[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] lastBulletTime:[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]Number[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace];[/FONT][/COLOR]
[COLOR=#0000FF][FONT=monospace]private[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]var[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] fireBullet:[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]Boolean[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace];[/FONT][/COLOR]
[COLOR=#0000FF][FONT=monospace]public[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]function[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] GameController()[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] {[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] }[/FONT][/COLOR]
[COLOR=#0000FF][FONT=monospace]public[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]function[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] startGame()[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] {[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] enemies = [/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]new[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]Array[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace]();[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] bullets = [/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]new[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]Array[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace]();[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] mcGameStage.[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]addEventListener[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace](Event.ENTER_FRAME,[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]update[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace]);[/FONT][/COLOR][COLOR=#808080][FONT=monospace]
[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]addEventListener[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace](Event.ADDED_TO_STAGE, gameAddedToStage ); [/FONT][/COLOR]
[COLOR=#0000FF][FONT=monospace]private[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]function[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]update[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace](evt:Event)[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] {[/FONT][/COLOR][COLOR=#808080][FONT=monospace]
[/FONT][/COLOR][COLOR=#808080][FONT=monospace]
[/FONT][/COLOR][COLOR=#808080][FONT=monospace]
[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]for[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] ([/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]var[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] i=enemies.[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]length[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] - 1; i >= 0; i--)[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] {[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] enemies[i].[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]update[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace]();[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] }[/FONT][/COLOR][COLOR=#808080][FONT=monospace]
[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]for[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] ([/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]var[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] i=bullets.[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]length[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] - 1; i >= 0; i--)[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] {[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] bullets[i].[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]update[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace]();[/FONT][/COLOR]
[COLOR=#0000FF][FONT=monospace]if[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] (bullets[i].notInScreen())[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] {[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] mcGameStage.removeChild(bullets[i]);[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] bullets.[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]splice[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace](i,1);[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] }[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] }[/FONT][/COLOR][COLOR=#808080][FONT=monospace]
[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]for[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] ([/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]var[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] i=bullets.[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]length[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] - 1; i >= 0; i--)[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] { [/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]for[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] ([/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]var[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] j=enemies.[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]length[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] - 1; j >= 0; j--)[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] {[/FONT][/COLOR]
[COLOR=#0000FF][FONT=monospace]if[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] (bullets[i].hitTestObject(enemies[j].collisionArea))[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] {[/FONT][/COLOR][COLOR=#808080][FONT=monospace]
[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] playerScore += enemies[j].getPointsWorth();[/FONT][/COLOR]
[COLOR=red][FONT=monospace] enemies.[COLOR=#0000FF]gotoAndPlay[/COLOR](27);[/FONT][/COLOR][COLOR=#808080][FONT=monospace]
[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] mcGameStage.removeChild(bullets[i]);[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] mcGameStage.removeChild(enemies[j]);[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] bullets.[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]splice[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace](i,1);[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] enemies.[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]splice[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace](j,1);[/FONT][/COLOR]
[COLOR=#0000FF][FONT=monospace]break[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace];[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] }[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] }[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] }[/FONT][/COLOR][COLOR=#808080][FONT=monospace]
[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]for[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] ([/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]var[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] j=enemies.[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]length[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] - 1; j >= 0; j--)[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] {[/FONT][/COLOR]
[COLOR=#0000FF][FONT=monospace]if[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] (player.collisionArea.hitTestObject(enemies[j].collisionArea))[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] {[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] mcGameStage.removeChild(player);[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] mcGameStage.removeChild(enemies[j]);[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] enemies.[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]splice[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace](j,1);[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] player = [/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]null[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace];[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] gameOver();[/FONT][/COLOR]
[COLOR=#0000FF][FONT=monospace]break[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace];[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] }[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] }[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] }[/FONT][/COLOR]
[COLOR=#0000FF][FONT=monospace]private[/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]function[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace] gameOver()[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] {[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] player = [/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]null[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace];[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] bullets = [/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]null[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace];[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] enemies = [/FONT][/COLOR][COLOR=#0000FF][FONT=monospace]null[/FONT][/COLOR][COLOR=#0F0F0F][FONT=monospace];[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace]}[/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace] } [/FONT][/COLOR]
[COLOR=#0F0F0F][FONT=monospace]}[/FONT][/COLOR]