Groups | Blog | Home
all groups > flash actionscript > october 2006 >

flash actionscript : x and y coordinates for movie clip



MichelleTen
10/10/2006 9:30:18 PM
I am developing a site and I have a button which when pressed goes to another
frame and attaches a movie to play, but it attaches it in the upper left
corner. I have tried adding an x and y coordinate in the attachMovieClip and
createMovieClip, but when doing that it shifts everything in the file to that
point. The entire canvas moves down. Any ideas?

on (press) {
gotoAndPlay("next");

this.createEmptyMovieClip("original_mc", depth++);


mcA = ["IceAd_swipe_mc", "Marriott1_mc"];
index = 0;

this.attachMovie(mcA[index], "mc", 0 (_x=448, _y=105));
this.onEnterFrame = function() {
if (mc._currentframe == mc._totalframes) {
index++;
if (index<mcA.length) {
removeMovieClip(mc);
this.attachMovie(mcA[index], "mc", 0);
} else {
removeMovieClip(mc);
}
}
};
}
.:}x-=V!P=-x{:.
10/10/2006 9:57:34 PM
ok i noticed you were creating a emptyMovieclip and not attaching to it,
instead you were attaching to _root , second i noticed in your attach method
you were using _x=448 when it should be _x:448, i also noticed your secont
attach method did not have _x and _y defined, and last I noticed you did not
clear your onenterframe when done ......try this:


on (press) {
gotoAndPlay("next");
this.createEmptyMovieClip("original_mc", depth++);
mcA = ["IceAd_swipe_mc", "Marriott1_mc"];
index = 0;
original_mc.attachMovie(mcA[index], "mc", 0, {_x:448, _y:105});
original_mc.onEnterFrame = function() {
if (mc._currentframe == mc._totalframes) {
index++;
if (index<mcA.length) {
removeMovieClip(mc);
this.attachMovie(mcA[index], "mc", 0, {_x:448, _y:105});
} else {
removeMovieClip(mc);
delete this.onEnterFrame;
}
}
};
}
coldMiner
10/10/2006 10:05:02 PM
a bit confusing code/path, but ok, try this:


on (press) {
gotoAndPlay("next");
this.createEmptyMovieClip("original_mc", depth++);
mcA = ["IceAd_swipe_mc", "Marriott1_mc"];
index = 0;
xx = 448;
yy = 105;
mc = this.attachMovie(mcA[index], "mc", 0);
mc._x = xx;
mc._y = yy;
trace(mc);
this.onEnterFrame = function() {
if (mc._currentframe == mc._totalframes) {
index++;
if (index<mcA.length) {
mc.removeMovieClip();
attachMovie(mcA[index], "mc", 0);
mc._x = this.xx;
mc._y = this.yy;
} else {
mc.removeMovieClip();
}
}
};
}
MichelleTen
10/11/2006 1:28:25 PM
Thanks for the help.

.:}x-=V!P=-x{:. your code kept everything from moving except the movie clip
which is what I wanted, but it was a little off on the coordinates. I'm not
sure why because they are exactly the same.

coldMiner: your code worked perfectly.
AddThis Social Bookmark Button