Hey all!:pirate3:
Im having a bit of a problem with duplicating a movieclip.
Im an AS noobie, so dont kill me for stupid mistakes lol.
Heres what im trying to do:
I have a button, when the <Insert> key is pressed and if the variable money at root is higher or equal, then make the variable “vpill” equals 1 and duplicate the MC “pill”.
Heres the code i have for that:
on (keyPress "<Insert>"){
if (_root.money >= 1000){
_root.vpill = 1;
_root.money -= 1000;
duplicateMovieClip(_root.pill, "pill"+1, _root.pill);
}
}
As for the MC “pill”, what i want is if the variable “vpill” equals 1 then at a random location (in a set range), place the mc, and if hitTest is true with “player” then _root.speed -= 1; make “vpill” equal 0 and remove the duplicated MC.
Heres the code i have on “pill” MC:
onClipEvent (load) {
randomNum=function(Minimum,Maximum){
return Minimum+Math.random()*(Maximum-Minimum);
}
if (_root.vpill == 1) {
pillx = randomNum(220, 480);
pilly = randomNum(70, 330);
this._x = pillx;
this._y = pilly;
if (this, hitTest(_root.player)) {
_root.speed -= 1;
this.removeMovieClip();
_root.vpill == 0;
}
}
}
NOTE: Variables are all placed in the root.
Thx in advance!
If u dont understand something, feel free to ask. THX! :crazy: