Skip to main content
Participant
December 5, 2009
Answered

A Noob at ActionScript. = D

  • December 5, 2009
  • 1 reply
  • 535 views

Hi all,

I have Flash 8 (ActionScript 2), and I am makin a little sniper game. I am working on a reloading system, but I am fairly new to actionscript. I know the basics, though I get one error, that when I fix, gives me another error. Here's the code so far...

The code is applied to a movieclip, that is the game's sniper scope. 'ammo' is the name of dynamic text box.

onClipEvent (mouseMove) {
_x = _root._xmouse;
_y = _root._ymouse;
}
if(ammo>=0){
on (press) {
  this.gotoAndPlay(51);
  _root.ammo-= 1;
}
} else {
if(ammo==0){
  on (press) {
   _root.ammo-=0;
   this.gotoAndPlay(70);
  }
}
}

Any help would be appreciated!    = D

This topic has been closed for replies.
Correct answer kglad

oops.  use:



onClipEvent (mouseMove) {
_x = _root._xmouse;
_y = _root._ymouse;
}

on(press){
if(ammo>0){
  this.gotoAndPlay(51);
  _root.ammo-= 1;
} else if(ammo==0){
   _root.ammo-=0;
   this.gotoAndPlay(70);
}
}

1 reply

kglad
Community Expert
Community Expert
December 5, 2009

try:


onClipEvent (mouseMove) {
_x = _root._xmouse;
_y = _root._ymouse;
}

on(press){
if(ammo>0){
  this.gotoAndPlay(51);
  _root.ammo-= 1;
} else {
if(ammo==0){
   _root.ammo-=0;
   this.gotoAndPlay(70);
}
}

Participant
December 5, 2009

I put it in, and got 4 errors. I fixed 3 of them, but still have this that I don't know how to fix:

**Error** Scene=Scene 1, layer=Mouse, frame=9:Line 10: 'else' encountered without matching 'if'
     } else {

Total ActionScript Errors: 1   Reported Errors: 1