Hey every1.
I have a question (I'm sure somebody asked it before, but I didn't find the threat...) :
How can I delete/destroy/whatever a movieclip during a movie? I made a game, in the game there is a zombie (movieclip), and when its life (life???) reaches zero, it should be destroyed. I tried "removeMovieClip(this)" and much more, but it didn't work, but also there were no errors.
I dont speak english very well,
so please excuse the mistakes.
hi i'm a newbie to flash action script and programming in general....i've tried to delete a movie clip using the removeMovieClip () command and also the .unload Movie () and they are not working instead the mc just stops pls any advice would be deeply appreciated.cos i'm currently going
may be i'm not doing it correctly tried..it again and it still ain't woring. here's my code may be u could tell me where i went worng...i'll be really greatful....
Code:
var hit = false;
var mcalienSpeed = 2;
function createObject (aliens) {
mcalien = _root.attachMovie ("aliens","aliens", 100);
mcalien._x = random (180)+10;
}
function resetmcalien () {
mcalien._x = random (180)+10;
mcalien._y = -20;
mcalien.removeMovieClip();
mcalien.restart = false;
hit = false
}
function movealien () {
if (mcalien._y<240)
{
mcalien._y += mcalienSpeed;
}
else{
resetmcalien();
}
if (mcalien.restart) {
resetmcalien();
}
}
i have also attached the fla incase this is not clear enough...
Last edited by patrick2010; 04-06-2010 at 06:04 AM.
Reason: added fla
To remove movie clips I have used this.unloadMovie () and it works perfectly. But the code has to be within the movie being unloaded. Maybe is it possible that the _root notation should be followed to address the movie clip with its strict path ?
hello i'm here again..trying to make my alien shoot but it's not responding properly instead its displaying the bullets in a straight line and not singularly and also displying them facing up instead of down. i also am trying to use the same bullet i used for the goodspacship...is that right or should i create a seperate bulletmovieclip......really appreciate the advice....cos it's driving me a lil bonkers
Code:
//move alien
function movealien() {
if(blnPlaying)
{
if (mcalien._y<240)
{
mcalien._y += mcalienSpeed;
var abl = _root.attachMovie("Bullet","Bullet" +i,i);
i++;
abl._x = _root.mcalien._x-10;
abl._y = _root.mcalien._y+10;
currentTime = getTimer();
bulletReady = false;
abl_array.push(abl);
if (currentTime + bulletDelay<=getTimer()){
bulletReady = true;
}
for (var j = 0; j<abl_array.length; j++)
{
var ab = abl_array[j];{
if (ab._y<+50){
ab._y += bulletspeed;
}
else {
ab.removeMovieClip();
}
if(!abhit){
if (ab.hitTest(mcSpaceship)){
hit = true;
_root.lives -=1;
if (_root.lives == 0){
blnPlaying == false;
txtMessage.txt = "Game Over! Press ok to play again"; }
}
resetmcalien();
ab.removeMovieClip();
}
}}
}
else
{
resetmcalien();
}
if (mcalien.restart)
{
resetmcalien();
}
// hittest for spaceship
if (!hitspaceship){
if (mcSpaceship.hitTest(mcalien)&& blnPlaying) {
hit = true;
_root.lives -= 1;
if (_root.lives == 0)
{
_root.score = 0;
blnPlaying = false;
txtMessage.text = "Game Over! Press ok to play again";
//mcSpaceship.removeMovieClip();
}
resetmcalien();
}
}
}
}
You need not assign the movie clip to a variable.._root itself means the main stage or the root..you are attaching your movie clip to the root or the main stage..so just _root.attachMovie ("aliens","aliens", 100); would be enough..also to remove or destroy the movie clip just specify its name..here it is aliens..
so aliens.removeMovieClip();
and for assigning x,y coordinates try it as aliens._x=random (180)+10;
aliens._y = -20;
I think you are working with actionscript 2.0..
I hope this works..
but I am not sure about it..