|
-
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?
-
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.
-
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();
}
}
-
Zombie Coder
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++;
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|