Actionscript Centering Issue....

Status
Not open for further replies.

t44studio

New Member
Messages
16
Reaction score
0
Points
0
I've been working on an image gallery for my website where a larger image pops up when you click on the thumbnail. I can't seem to get it centered properly if the window is not the exact size of the stage. :rant2:I tried looking at other forums, but I can't seem to figure out what the heck I'm doing wrong. Any help would be appreciated.

The code with the problem:

function callLargeImage(myNumber) {
myURL = images[g][myNumber].attributes.large;
lheight = images[g][myNumber].attributes.h;
lwidth = images[g][myNumber].attributes.w;

_root.createEmptyMovieClip("largeImage_mc", _root.getNextHighestDepth());

var myDropFilter = new flash.filters.DropShadowFilter(4, 45, 0x000000, 0.7, 10, 10, 2, 10);
var myFilters:Array = largeImage_mc.filters;
myFilters.push(myDropFilter);
largeImage_mc.filters = myFilters;

var largeClipLoader = new MovieClipLoader();
var largePreloader = new Object();

largePreloader.onLoadInit = function(target) {
largeImage_mc._x = Stage.width/2 - largeImage_mc._width/2;
largeImage_mc._y = Stage.height/2 - largeImage_mc._height/2;
}

largeClipLoader.addListener(largePreloader);

largePreloader.onLoadStart = function(target) {
target.createTextField("my_txt", large_mc.getNextHighestDepth, 20, 20, 200, 20);
target.my_text.selectable = false;
target.my_text.font = "Arial";
target.my_text.bold = true;
target.onRelease = function(){
this.removeMovieClip();
}
};

largePreloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
target.my_txt.text = String(Math.floor((loadedBytes/totalBytes) * 100)) + " %";
};

largePreloader.onLoadComplete = function(target) {
new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
target.my_txt.removeTextField();
};

largeClipLoader.loadClip(myURL, largeImage_mc);
};
Edit:
Out of some freak accident, it decided to work(?). Go figure.

Please close this thread. :)
 
Last edited:

VPmase

New Member
Messages
914
Reaction score
1
Points
0
I recommend you use parentheses around the math for the centering to give it more organized but if it works your choice.

Thread Closed.
 
Status
Not open for further replies.
Top