i did a game, and there was two kindes of attached movie clips and i wrote this code at one cherecter:
[LEFT]
[LEFT]_root.main1.onEnterFrame = function() {
i++;
if (Key.isDown(Key.CONTROL) and _root.am1.at1.w5._visible==1 and _root.ep1._width>=20 and sd==1) {
sd=0;
_root.main1.gokus.gotoAndPlay(97);
}
_root.attachMovie("disk","d"+i,i);
_root["d"+i]._x=_root.main1._x;
_root["d"+i]._y=_root.main1._y-10;
if (_root.main1._xscale==100) {
_root["d"+i].onEnterFrame = function() {
this._x-=20;
};
}
if (_root.main1._xscale==-100) {
_root["d"+i].onEnterFrame = function() {
this._x+=20;
};
}
};[/LEFT]
[/LEFT]
and in the 2nd one i wrote this:
[LEFT]
_root.main2.onEnterFrame = function() {
t++;
if (Key.isDown("90") and _root.am2.at2.w5._visible==1 and _root.ep2._width>=20 and sdt==1) {
sdt=0;
_root.main2.gokus.gotoAndPlay(97);
}
_root.attachMovie("disks","s"+t,t);
_root["s"+t]._x=_root.main2._x;
_root["s"+t]._y=_root.main2._y-10;
if (_root.main2._xscale==100) {
_root["s"+t].onEnterFrame = function() {
this._x-=20;
};
}
if (_root.main2._xscale==-100) {
_root["s"+t].onEnterFrame = function() {
this._x+=20;
};
}
};
when i did this and sometimes press Ctrl and “z” at the same time the 2nd movie clip wasnt attached and it was only playing frame 97 but when i put the code of the attachment in frame 97 it worked, why is thet?
thanks for the helpers[/LEFT]
this is probably because you have the gotoAndPlay(97) frame before you have the attach movieClip code try moving the first if statement to the bottom of your code and see if that helps.
alright what do you have your i and t variable intialize at? … if they are the same, then you are overwriting the movieclip in that depth
so let’s say you have them both set to zero
var i = 0;
var t = 0;
if you hit the buttons at teh same time only one will show because they are both trying to place a movieclip into depth level 0.
so trying starting them off at different values like
var i = 0;
var t = 100;
just so they don’t overlap, only issue i can see with this is if they keep hitting the button to trigger i and not t then you’ll wind up back to where you are now like so
i == 100;
and
t == 100;
if they hit both those buttons again at the same time you will get the same problem.
you might need to do some other check like
// in your first bit of code before after i++;
i++;
if(i >= 99){
i = 0;
}
// rest of code here ....
// then have t something like
t++;
if(t >= 199){
t = 100;
}
// other code ...
-Use AS tags when posting
-That’s just a shortened version of what you have already… post a fla?
-Optix, You can’t have two objects at the same depth, one will be removed.