PDA

View Full Version : [Flash] Quick question +rep



Blinger1
18-02-2009, 12:52 PM
What is wrong with my code?

onClipEvent (load) {
var weaponz = 0;
var taken = 0;
}
onClipEvent (enterFrame) {

// make the weapon
if (taken == 0) {
_root.weapon.duplicateMovieClip("weapon"+weaponz,weaponz);
eval("_root.weapon"+weaponz)._x = 161;
eval("_root.weapon"+weaponz)._y = 280;
taken == 1;
}

// a basic hittest
if (this.hitTest(_root.ball)) {
this.removeMovieClip();
}
}It kind of works, it will draws the item i need drawn but then nothing else happens?

I need it so it only draws ONE box, not an infinite ammount..

I thought if i change the "taken == 1" to "taken = 1" it would work, but it always shows "0 0 1 0 1 0" in the output (a space represents a new line)..


+ rep to whoever helps
:)

[Oli]
19-02-2009, 03:16 PM
Try the following.

Also:
When you stated: taken == 1; it will ofcourse not work.
a double == means it will check if something is equal to something else.
a single = means you give a new content to ex. a variable.
and += means you add something to whats already in the content. (ex counting up)
and -= will do the same but withdraw something (counting down)




onClipEvent (load) {
var weaponz = 0;
var taken = true;
}
onClipEvent (enterFrame) {

// make the weapon
if (taken == true) {
_root.weapon.duplicateMovieClip("weapon"+weaponz,weaponz);
eval("_root.weapon"+weaponz)._x = 161;
eval("_root.weapon"+weaponz)._y = 280;
taken = false;
}

// a basic hittest
if (this.hitTest(_root.ball)) {
this.removeMovieClip();
}
}

Blinger1
19-02-2009, 10:14 PM
That didn't work.. it does not get "picked up"

Want to hide these adverts? Register an account for free!