View Full Version : AttachMovieClip not transfering code?
Sirisian
March 24th, 2005, 04:23 PM
i made a movie clip and made it so when i clikc on it another movie lip is created inside. That movieclip should move forward but is doesn't. look at the 10 lines of code and try and find a problem. Heres the code if u don't want to look at the .fla
on the box:
on (press) {
++i
_root.box.attachMovie(_root.bullet,"bullet"+i,i)
}
on the bullet:
onClipEvent (load) {
this._x = _root.box._x;
this._y = _root.box._y;
}
onClipEvent (enterFrame) {
if (this._name != "bullet") {
this._y -= 5;
}
}
MichaelxxOA
March 24th, 2005, 04:50 PM
if you already have the movie clip on the stage, and have the code on the movie clip, then why don't you just use duplicateMovieClip?
Sirisian
March 24th, 2005, 04:58 PM
it has to go inside of the box....i'd show u the actual game but the code is like 1000 lines. anyone? I just updated the .FLA
Sirisian
March 24th, 2005, 11:43 PM
did i phrase the question wrong or something? If you don't understand what im asking then: I need someone to find out how to use the attach movieclip function to put a movieclip into another movieclip and have it move.
stwingy
March 25th, 2005, 02:21 AM
i made a movie clip and made it so when i clikc on it another movie lip is created inside. That movieclip should move forward but is doesn't. look at the 10 lines of code and try and find a problem. Heres the code if u don't want to look at the .fla
on the box:
on (press) {
++i
_root.box.attachMovie(_root.bullet,"bullet"+i,i)
}
on the bullet:
onClipEvent (load) {
this._x = _root.box._x;
this._y = _root.box._y;
}
onClipEvent (enterFrame) {
if (this._name != "bullet") {
this._y -= 5;
}
}
the code you have will work if you add another bracket and put an instance on the stage somewhere
onClipEvent (enterFrame) {
if (this._name != "bullet") {
this._y -= 5;
}
}
maybe a better approach is to put on the timeline containing box
velY=5
box.onPress = function() {
clip = this.attachMovie("bullet", "bullet"+i, i);
clip.onEnterFrame = move;
i++;
};
function move() {
this._y -= vely;
if (this._y<-this._parent._y) {
removeMovieClip(this);
velY = 5;
}
}
Sirisian
March 25th, 2005, 10:11 AM
could u post a working version of this, I still can't get it t work for some reason.
Sirisian
March 25th, 2005, 10:26 AM
nvm thx!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.