well i am making a game where you shoot planes and my shooting actionscript doesnt seem to work and im not sure why.
onClipEvent (load) {
moveSpeed = 10;
_root.bullet._visible = false
bulletCounter = 1;
bulletSpeed = 17;
this._x = _root.plane._x;
this._y = _root.plane._y-30;
}
onClipEvent (enterFrame) {
this._y -= bulletSpeed;
if (this._y<=-50) {
this.removeMovieClip();
}
}
if (Key.isDown(Key.SPACE)) {
bulletCounter++;
_root.bullet.duplicateMovieClip("bullet"+bulletCounter, bulletCounter);
_root["bullet"+bulletCounter]._visible = true;
}
It seems right but when i try it out it says in the out put box Scene=Scene 1, Layer=Layer 1, Frame=1: Line 15: Statement must appear within on/onClipEvent handler
if (Key.isDown(Key.SPACE)) {
can someone help me
-xrox2
The error message is pretty clear about the problem. The code from line 15 down needs to be in some form of an on/onClipEvent handler, just like the rest of the code is in onClipEvent handlers.
would you be able to fix it?
I can try to help you to fix it yourself, but I won't fix it for you. If you have no knowledge of how to use Flash, I won't be taking the time to teach you.
See if this works for you. Remove those last lines from where they currently are. Change them to be what you see below and place them in a keyframe of an actions layer on the timeline...
this.onEnterFrame = function (){
if (Key.isDown(Key.SPACE)) {
bulletCounter++;
_root.bullet.duplicateMovieClip("bullet"+bulletCounter, bulletCounter);
_root["bullet"+bulletCounter]._visible = true;
}
}