PDA

View Full Version : Why Dousnt This Work?



yhack
April 18th, 2004, 06:06 AM
on the bullet i have:


onClipEvent (load) {
if (_root.fire == 1) {
this._x = _root.Cannon._x;
this._y = _root.cannon._y;
}
}
onClipEvent (load) {
this._visible = 0;
}
onClipEvent (enterFrame) {
if (this != _level0.bullet) {
if (_root.fire == 1) {
this._y -= 5;
this._visible = 1;
}
if (this._y<0) {
this.removeMovieClip();
}
}
}

and on the cannon i have this:

onClipEvent (enterFrame) {
if (Key.isDown(Key.Left)) {
_root.cannon._x -= 10;
}
if (Key.isDown(Key.Right)) {
_root.cannon._x += 10;
}
}
onClipEvent (load) {
if (Key.isdown(key.space)) {
_root.fire = 1;
_root.i += 1;
duplicateMovieClip(_root.bullet, "bullet"+i, i);
}
}


The movement works but why dousnt it fire??

exfusion
April 18th, 2004, 08:18 AM
hi there.
upload your fla on this thread or email it to me on (exfusion@hotmail.com) i can modify it and get it working for you.

regards
ExFuSiOn

scotty
April 18th, 2004, 08:19 AM
Put your if-statements onEnterFrame;)

scotty(-:

senocular
April 18th, 2004, 08:25 AM
you can only have one onClipEvent(load) statement at a time

Though on() statements can duplicate, onClipEvent() statements cannot



(not sure thats the real issue, just something I noticed at a glance)

exfusion
April 18th, 2004, 08:54 AM
ur right Senocular, he also has a lot of mistakes using variable names, he spells them differently. this is why i believe that there is more than one problem here ,so posting the fla would moke it easier on everyone.

Regards

Johnny64
April 18th, 2004, 08:55 AM
and another thing

_root.i += 1;
duplicateMovieClip(_root.bullet, "bullet"+i, i);

_root.i and i are not the same in your code!

because just i in this chase is
_root.cannon.i;

so to fix that make them them all _root.i or all just i

:)

yhack
April 18th, 2004, 09:06 AM
ok heres the file

send back when youve done the actions please!

Johnny64
April 18th, 2004, 09:18 AM
Keep it simple ;)


onClipEvent (enterFrame) {
if (this == _level0.bullet) {
this._visible = 0;
this._x = _root.cannon._x;
this._y = _root.cannon._y;
} else {
this._visible = 1;
this._y -= 5;
if (this._y<0) {
this.removeMovieClip();
}
}
}

thats your new cannon code
and then if you do what said my last post, it works.

yhack
April 18th, 2004, 09:24 AM
that makes the cannon go upwards

Johnny64
April 18th, 2004, 09:28 AM
wooooops:trout::trout::trout::trout::trout::trout: :trout::trout::trout::trout::trout::trout::trout:

that code is for the bullet not the cannon

my mistake *lol*

yhack
April 18th, 2004, 09:28 AM
can u just do it from my file because i dont understand

Johnny64
April 18th, 2004, 09:44 AM
did you try to understand?

yhack
April 18th, 2004, 09:51 AM
Thx!!!!!!!!!!

Ye i did try but i cant understand why i cant understand anything