Why doesnt my code work?... help please

  • Adde
  • Beginner
  • Beginner
  • Adde
  • Posts: 47

Post 3+ Months Ago

Hi..

My code doesnt work could any1 please help me? The code im using is:

Code: [ Select ]
onClipEvent (load) {
moveSpeed = 20;
}
onClipEvent (enterFrame) {
if (Key.isDown (Key.RIGHT)) {
this._x += moveSpeed;
} else if (Key.isDown (Key.UP)) {
this._y -= moveSpeed;
} else if (Key.isDown (Key.DOWN)) {
this._y += moveSpeed;
} else if (Key.isDown (Key.LEFT)) {
this._x -= moveSpeed;
}
}
livesLeft = 2
function justDied(){
 livesLeft--;
 if(livesLeft > 0){
  gotoAndPlay(reinkarnationAnimation); 
 }else{
  gotoAndPlay(deathAnimation);
 }
}
  1. onClipEvent (load) {
  2. moveSpeed = 20;
  3. }
  4. onClipEvent (enterFrame) {
  5. if (Key.isDown (Key.RIGHT)) {
  6. this._x += moveSpeed;
  7. } else if (Key.isDown (Key.UP)) {
  8. this._y -= moveSpeed;
  9. } else if (Key.isDown (Key.DOWN)) {
  10. this._y += moveSpeed;
  11. } else if (Key.isDown (Key.LEFT)) {
  12. this._x -= moveSpeed;
  13. }
  14. }
  15. livesLeft = 2
  16. function justDied(){
  17.  livesLeft--;
  18.  if(livesLeft > 0){
  19.   gotoAndPlay(reinkarnationAnimation); 
  20.  }else{
  21.   gotoAndPlay(deathAnimation);
  22.  }
  23. }



What can it be ? I have no clue.. ^^ ( but im a noob to :D )
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

You can't define variables and functions outside an event handler on a movieclip... if they only need to be declared once, put them in the onClipEvent(load) command.

Is that the problem?

Not entirely sure WHICH part of the code isn't working since you didn't say.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 26 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.