i know i must be doing something simple wrong, but i can’t spot it. i am trying to get an empty movieclip to center after a jpg loads into it. the images load, but they don’t center. my first attempt (using loadMovie) would read the size too quickly and would only center after a second click. i thought using a MovieClipLoader would work, but my leftEdge always returns 350. i’m getting a 0 value for _width.
on a related topic, i want to apply a DropShadowFilter to the same empty movieclip. i haven’t tried it with the MovieClipLoader, but it didn’t work using loadMovie. any ideas on that? if i have to, i can create a generic dropshadow and position and scale it accordingly, but again, i will need to be able to read the size and position of the empty movieclip.
thanks
craig
var mcl:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
mcl.addListener(mclListener);
function imageLoader() {
var imgName:String = _root.section+_root.proj+"-"+_root.imgCnt+".jpg";
mclListener.onLoadComplete = function() {
var leftEdge:Number = (350-(_root.holder._width/2));
_root.holder._x = leftEdge;
trace("left side: "+leftEdge);
};
mcl.loadClip(imgName,_root.holder);
}
[QUOTE=mrwicked;2348584]yea need to do something like
target._X = 0 - (target._width / 2)[/QUOTE]
how is that different from what i did? i only broke it into 2 lines so that i could trace the leftEdge easier. i think the problem is that it is reading the width of the empty_mc rather than the width of the jpg i am loading into it. or maybe i’m misunderstanding you.
var leftEdge:Number = (350-(_root.holder._width/2));
**_root.holder._x = leftEdge;
**trace("left side: "+leftEdge);
well first use the onLoadInit function rather than onLoadComplete. Change 350 to a 0 and see if it works. I don’t understand how you think what you did is the same as mine. The concept is the same, but the values sure aren’t, unless I didn’t understand your initial post.
If its returning 0 for your width, then changing onLoadComplete to onLoadInit should return the correct width.
OnLoadInit fixed it. the centering works now. i wasn’t clear on it’s usage.
the reason i am using 350 instead of 0, is that it needs to center at 350. 0 would put the left half of the image off screen. i wasn’t clear in my first post.
thanks for your help.
ps: my DropShadowFilter works now too. you and Init rule.