What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

gotoAndPlay dont work


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

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]
 
Have you tried "enemies[j].gotoAndPlay(27);" ? Because I take it that the elements of the array are supposed to be movieclips. So, you should tell the movieclip (the element of the array enemies) to play an animation instead of telling an array-type to play an animation. If not, then I probably didn't understand the code correctly =P
 

Back
Top