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…?
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?
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]
[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]
[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!
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!).
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!
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