开发者

AS2 Center loadMovie MovieClip

I'm dynamically cr开发者_如何学Goeating an empty movieclip inside another movieclip to load an image into it. How could i make sure that this image is always centred in the movieclip?

Also, if i have a attached movieclip named E.G. 1M how do i find out the x and y position to make it appear next to each other?


To center an object in a container, you need to do the following

 Pseudo Code 
 object.x = ( container.width - object.width )/2;
 object.y = ( container.height - object.height )/2;

since you need all these dimensions to be set before centering an object, you can only apply the above after your image has loaded.

You would typically add that code in your complete event listener. If your image is loaded inside a MovieClip and you want that MovieClip to be centered within its container, you can apply the same formula, only you'll apply it to the image container ( object ) & the container parent ( container ).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜