View Full Version : attachmovie help
coolioman
12-06-2005, 08:09 PM
I have a movieclip attached on the stage in a random position every 5 seconds. But when it attaches the movieclip, it overwrites the old one. i.e deletes the previously attached one and creates a new one. I do not want the previously attached movieclip to be replaced with the other one, I just want it attached with out affecting the other attached MC's.
help, please!
you need to add the third paramater of attachMovie which is depth
you can do this
_root.attachMovie('yourMovie', 'uniqueName', _root.getNextHighestDepth());
and it shoudl fix all your problems
senocular
12-06-2005, 08:13 PM
you have to give it a different depth value. Movie clips cant exist on the same depth so whenever you make a new one using a depth value used by another movie clip, it replaces it.
coolioman
12-07-2005, 12:55 AM
thanks.
I decided to designate a position for the attached movie to be placed, and the first one IS placed there, but the others are placed in the top left corner of my movie.
I am using this code on a frame inside of a movieclip:
attach=(random(6));
if(attach == 4){
_root.attachMovie('box1', 'newclip', _root.getNextHighestDepth());
_root.newclip.._x = 568.4;
_root.newclip._y = 175.7;
}
please help!
var attach:Number=random(6);
if(attach == 4){
var clip:MovieClip= _root.attachMovie('box1', 'newclip', _root.getNextHighestDepth());
clip._x = 568.4;
clip._y = 175.7;
}
coolioman
12-07-2005, 01:25 AM
ok that works, but I cannot perform collision detection with the attached movies. Basicly I want this to happen: if manmc hits the attached movie, remove manmc.
thanks, hope you can help.
coolioman
12-07-2005, 03:25 AM
does anyone know whats wrong?
Electric Dandy
12-07-2005, 05:51 AM
Collisions are detected with hitTest:
my1_mc.onPress = function() {
my1_mc.startDrag();
};
my1_mc.onRelease = function() {
my1_mc.stopDrag();
};
my2_mc.onPress = function() {
my2_mc.startDrag();
};
my2_mc.onRelease = function() {
my2_mc.stopDrag();
};
my1_mc.onEnterFrame = function() {
if (this.hitTest(my2_mc) == true) {
trace(my1_mc+" "+"hit"+" "+my2_mc);
}
// or
my2_mc.onEnterFrame = function() {
if (this.hitTest(my1_mc) == true) {
trace(my2_mc+" "+"hit"+" "+my1_mc);
}
};
coolioman
12-07-2005, 01:05 PM
i already know how to perform hittest, But i cant get it working with the attached movie. How do I do this?
coolioman
12-08-2005, 01:32 PM
My attached movie has a movieclip inside it that has this code on it:
onClipEvent(enterFrame){
this._x -=4;
}
onClipEvent(enterFrame){
if(this.hitTest(_root.man)){
trace("ouch");
}
}
The first attached movie works, but with all of the rest, it doesn't. How do i make it work?
skillet
12-08-2005, 08:40 PM
I'd like to do the same thing, but instead of having a random position, I'd like it randomly "attachMovie" from my library. I assume I would have to put everything into an array first and then pick randomly from it, but I haven't been able to find a solution.
This is the direction I'm going.
items = ["artExchange","austinVentures"];
box.attachMovie (items,"newLogo", 1);
Thanks!
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.