A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Destroy/Delete a Movieclip???

  1. #1
    Junior Member
    Join Date
    Oct 2004
    Location
    Hannover, Germany ; (Expo City 2000)
    Posts
    6

    Destroy/Delete a Movieclip???

    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.

  2. #2
    - carly1979's Avatar
    Join Date
    May 2004
    Location
    down south, UK
    Posts
    1,778
    you might have more luck posting this question in the games forum.....

    <http://www.flashkit.com/board/forumd....php?forumid=5>

    goodluck!

    carly

  3. #3
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    my_clip.unloadMovie();

  4. #4
    Junior Member
    Join Date
    Oct 2004
    Location
    Hannover, Germany ; (Expo City 2000)
    Posts
    6
    thx oldnewbie!
    it worked perfectly!
    I dont speak english very well,
    so please excuse the mistakes.

  5. #5
    Junior Member
    Join Date
    Apr 2010
    Posts
    8

    trying to delete a movieclip thru as2

    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

  6. #6
    Senior Member
    Join Date
    Dec 2009
    Posts
    109
    For removeMovieClip() to work, the movie clip needs to be created or attached through Actionscript. I don't know about .unloadMovie().
    Syntax Error

  7. #7
    Junior Member
    Join Date
    Apr 2010
    Posts
    8
    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...
    Attached Files Attached Files
    Last edited by patrick2010; 04-06-2010 at 06:04 AM. Reason: added fla

  8. #8
    Senior Member
    Join Date
    May 2009
    Posts
    213
    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 ?

  9. #9
    Senior Member
    Join Date
    Dec 2009
    Posts
    109
    Try changing "mcalien.removeMovieClip()" to "aliens.removeMovieClip()" If that doesn't work then I'm stumped.
    Syntax Error

  10. #10
    Junior Member
    Join Date
    Apr 2010
    Posts
    8
    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();
    			}
    			
    		}
    	}
    }

  11. #11
    Registered User
    Join Date
    Feb 2013
    Posts
    1
    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..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center