A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: remove all movieclips?

Hybrid View

  1. #1
    Member
    Join Date
    Apr 2007
    Location
    Greece
    Posts
    92

    remove all movieclips?

    is there any way of doing this?

    oh and heres a second question

    Code:
    BulletClip = _root.attachMovie("rbullet", "pbullet"+NextDepth, NextDepth);
    in that AS, does the pbullet stand for the instance name?

  2. #2
    crossconscious
    Join Date
    Sep 2005
    Location
    Belgium
    Posts
    1,188
    Easiest way to do this is attaching everything to a container, and then when you remove the container, everything will be gone.

    in that AS, does the pbullet stand for the instance name?
    Yeah, but it will be pbullet0, pbullet1, etc, depending on the value of NextDepth.

    But I never use the instance name (except for things that I put on the stage at design time). The attachMovie method returns a reference to your object, and that is what I use.

    Also, a little tip : use lowercase for the first letter of variable names (ie bulletClip and nextDepth). Uppercase on the first letter suggests it's a class name. It's not necessary at all, but it's a coding convention used by programmers around the world in a lot of languages.

  3. #3
    Member
    Join Date
    Apr 2007
    Location
    Greece
    Posts
    92
    so how would i go about giving an instance name to a bullet if i use the getnexthighestdepth to attach the bullet?? if it is supposed to show the depth, which is up to the computer??

    Code:
    var scale = _root.player._xscale / 100
    var depth = _root.getNextHighestDepth()
    var BulletClip = _root.attachMovie("pistol", "pshot"+depth, depth);
    BulletClip._y = _root.player._y - 28;
    BulletClip._x = _root.player._x + 23 * scale;
    BulletClip.speed = 6 * scale;
    
    BulletClip.onEnterFrame = function(){
    	
    	this._x += this.speed;
    	
     	if (this._x > 550){
    		
      		this.removeMovieClip();
     	}
    if (this._x < 0){
    		
      		this.removeMovieClip();
     	}
    	}

  4. #4
    Zombie Coder EvilKris's Avatar
    Join Date
    Jun 2006
    Location
    Fukuoka, Japan.
    Posts
    796
    Just don't use getNextHighestDepth(). It'll only cause you problems sooner or later anyway.
    Use a tag variable instead and increment at every instantation of your bullet.

    depth=0;
    _root.createEmptyMovieClip("container", 1); //depth 5000

    ///CODE
    var BulletClip = _root.container.attachMovie("pistol", "pshot"+depth, depth);
    depth++;

  5. #5
    Member
    Join Date
    Apr 2007
    Location
    Greece
    Posts
    92
    ok thx ill try it out

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