is there any way of doing this?
oh and heres a second question
in that AS, does the pbullet stand for the instance name?Code:BulletClip = _root.attachMovie("rbullet", "pbullet"+NextDepth, NextDepth);
Printable View
is there any way of doing this?
oh and heres a second question
in that AS, does the pbullet stand for the instance name?Code:BulletClip = _root.attachMovie("rbullet", "pbullet"+NextDepth, NextDepth);
Easiest way to do this is attaching everything to a container, and then when you remove the container, everything will be gone.
Yeah, but it will be pbullet0, pbullet1, etc, depending on the value of NextDepth.Quote:
in that AS, does the pbullet stand for the instance name?
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();
}
}
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++;
ok thx ill try it out