Help! Photo Gallery Tut - Center images within movie clip?

This could be a really asinine question, and I’m sorry if it’s already been asked (read through almost all of the posts and came up with nothing…).

The Photo Gallery tutorial is just fantastic and my little gallery is coming along great, EXCEPT that I can’t make the images centered within the movie clip.

Have tried dragging the movie clip almost off the stage, which works, but is disorganized and I have a great deal of trouble figuring out where to put the forward and back buttons…

Can anybody help? Is there a piece of code that will automatically center my images within my movie clip? If it’s a matter of x and y coordinates, should I just use trial and error to figure out what numbers to put in, or is there some sort of trick…?

Thanks!

A similar thing was handled here…

http://www.kirupaforum.com/forums/showthread.php?s=&threadid=26238

Hi. Thanks.

Still not going, though…any idea why images might load into the bottom right corner of movieclip by default, with their little heads peeking out of the frame?

I’m an actionscript idiot. Am I doing something terribly wrong?

By default anytime it loads to the upper left corner, you can’t change that unless you use AS to manually move it.

It would be the same method as the previous link I posted only without the /2 in there.

Thank you so very much. Will try that. One last moment of ignorance…where in the enormous string of code that I already have should I put that? So far it goes like this (have left in the original tutorial notes for clarity):
[AS]//Code written by sbeener (suprabeener)
/*
i wrote this code, but you can use and abuse it however you like.
the methods are defined in the order which they occur to make it
easier to understand.
*/
// variables ------------------------------------------
// put the path to your pics here, include the slashes (ie. “pics/”)
// leave it blank if they’re in the same directory
this.pathToPics = “archonpics/”;
// fill this array with your pics
this.pArray = [“arch1.jpg”, “arch2.jpg”, “arch3.jpg”, “arch4.jpg”, “arch5.jpg”, “arch6.jpg”, “arch7.jpg”, “arch8.jpg”, “arch9.jpg”, “arch10.jpg”, “arch11.jpg”, “arch12.jpg”, “arch13.jpg” ];
this.fadeSpeed = 10;
this.pIndex = 0;
// MovieClip methods ----------------------------------
// d=direction; should 1 or -1 but can be any number
//loads an image automatically when you run animation
loadMovie(this.pathToPics+this.pArray[0], _root.photo);
MovieClip.prototype.changePhoto = function(d) {

// make sure pIndex falls within pArray.length
this.pIndex = (this.pIndex+d)%this.pArray.length;
if (this.pIndex<0) {
	this.pIndex += this.pArray.length;
}
this.onEnterFrame = fadeOut;

};
MovieClip.prototype.fadeOut = function() {
if (this.photo._alpha>this.fadeSpeed) {
this.photo._alpha -= this.fadeSpeed;
} else {
this.loadPhoto();
}
};
MovieClip.prototype.loadPhoto = function() {
// specify the movieclip to load images into
var p = _root.photo;
//------------------------------------------
p._alpha = 0;
p.loadMovie(this.pathToPics+this.pArray[this.pIndex]);
this.onEnterFrame = loadMeter;
};
MovieClip.prototype.loadMeter = function() {
var i, l, t;
l = this.photo.getBytesLoaded();
t = this.photo.getBytesTotal();
if (t>0 && t == l) {
this.onEnterFrame = fadeIn;
} else {
trace(l/t);
}
};
MovieClip.prototype.fadeIn = function() {
if (this.photo._alpha<100-this.fadeSpeed) {
this.photo._alpha += this.fadeSpeed;
} else {
this.photo._alpha = 100;
this.onEnterFrame = null;
}
};
// Actions -----------------------------------------
// these aren’t necessary, just an example implementation
this.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
this.changePhoto(-1);
} else if (Key.getCode() == Key.RIGHT) {
this.changePhoto(1);
}
};[/AS]

[edit by lostinbeta]PLEASE use the vbCode AS tags!!![/edit]

I believe in this area here…

[AS]MovieClip.prototype.loadMeter = function() {
var i, l, t;
l = this.photo.getBytesLoaded();
t = this.photo.getBytesTotal();
if (t>0 && t == l) {
this.onEnterFrame = fadeIn;
} else {
trace(l/t);
}
};[/AS]

It would go a little something like…

[AS]MovieClip.prototype.loadMeter = function() {
var i, l, t;
l = this.photo.getBytesLoaded();
t = this.photo.getBytesTotal();
if (t>0 && t == l) {
this.photo._x -= this.photo._width;
this.photo._y -= this.photo._height;
this.onEnterFrame = fadeIn;
} else {
trace(l/t);
}
};[/AS]

That will make it attach the lower right corner.

I’m being vague, I guess, images are already in the lower right corner…want em’ in the middle of the movie clip…

Really, I’m a total actionscript newbie, so anything that might help me keep those bad boys centered no matter what would be great!

Thanks so much.

[AS]MovieClip.prototype.loadMeter = function() {
var i, l, t;
l = this.photo.getBytesLoaded();
t = this.photo.getBytesTotal();
if (t>0 && t == l) {
this.photo._x -= this.photo._width/2;
this.photo._y -= this.photo._height/2;
this.onEnterFrame = fadeIn;
} else {
trace(l/t);
}
};[/AS]

Then divide it by 2.

But I don’t see why they would be loading in the lower right corner. The image that gets loaded automatically attaches its upper left corner to the registration point of the clip you load to, unless you made it do elsewise.

If your Flash is just being weird (well… retarded…lol), then you may need to change -= in the above code to +=

Apparently my flash is simply mongoloid! (or I am). It now centers the first one, and as I move through the set, gradually moves each image further and further to the right till they float off into space and disappear! Egad. Thanks so much for trying to make this thing go!

Really? Can you attach your files so I can have a look and see if I can do anything?

And…lol… mongoloid… I haven’t heard that phrase in like a year!!!

Ah hah!

OK, so dorky old me has now taken the instance of the movie clip off the main stage and re-published and it looks FANTASTIC, all centered and purdy…except that now the buttons have disappeared. Gad!

The first problem seems to have solved itself, and now, true to Murphy’s law, a new problem has reared its ugly little head…any ideas why buttons are gone? (have tried putting them absolutely EVERYWHERE, in movie clip, on main stage, everywhere!).

is your image covering them up?

If not I have no clue. What did you change to get it to work? That might provide some clues.

Well, I pulled the movie clip “containing” the pictures, but not the buttons off the main stage and re-tested. Lovely little box with first picture centered shows up. But nothing else. Not a button to be found. I’m fiddin’ to give up on this. you are my actionscript hero(ine) of the evening!

So you just removed that clip? You didn’t replace it with anything?

If so, I think it may be loading to your _root level and replacing the buttons. The clip it attaches to is important.

And I would be “hero” :slight_smile:

If you could .zip your files and either attach them to the forum or upload them for download I would gladly take a look and see what I can do :slight_smile:

Can’t do anything more for the evening, as have about two brain cells left and they’re in pain at the moment. Thanks for all your help. Will continue later if not solved by dawn.

Alright man, I wish you the best of luck in getting this to work.

And I know how you feel, I have had issues that I could solve and I just wanted to rip my head off and throw it through the monitor, but remember… that solves NOTHING… hehe :slight_smile: