all groups > flash actionscript > november 2004 >
You're in the

flash actionscript

group:

Center Movie Clip on Stage


Center Movie Clip on Stage Studious
11/15/2004 9:39:11 PM
flash actionscript:
This is probably a simple peice of AS, but I'm having some problem with it.
Here is my situation: I am loading an external .jpg into a movie clip (which
is no problem), named 'image.' Upon loading the .jpg, I would like it to
center on the stage; the .jpg is 100 pixels wide and my stage is 200 pixels
wide. I've tried the followlng: image._x = (200-image._width)/2; (...it
seems to ignore the image._width parameter and just move the .jpg to x=100.)
Any help in this matter would be greatly appreciated. Chris
Re: Center Movie Clip on Stage NSurveyor
11/15/2004 9:45:47 PM
I'm guessing the problem is, that you are trying to center the image before you
know for a fact the image has loaded. To fix this: add an onLoad event handler
with image._x = (200-image._width)/2 in it.
Re: Center Movie Clip on Stage Studious
11/15/2004 9:54:01 PM
Actually, I do know it loads, because I have it loading from my computer.
However, I did try a loadMovie action in the second frame of the timeline, with
a third frame being a stop frame; the first frame is empty. The empty movie
clip is present as its own layer for all 3 frames...I attached this to the
empty movie clip: onClipEvent (load){ image._x = (200-image._width)/2; }
Thank you for your help.
AddThis Social Bookmark Button