Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
simplyfrank

SlideShow Example: centering images in _imageContainer

Recommended Posts

Cheers,

 

Wondering if anyone can help. Driving myself nuts :(

 

I've been reengineering the slideshow example to load my own images of different sizes with fluid layout.

When I take out the width and height from the images size correctly but they are all left aligned. Is it possible to center them with in the container or stage?

 

Thanks

 

new ImageLoader("assets/images/" + image.@name + ".jpg", {name:image.@name + "Image",   scaleMode:"proportionalInside", bgAlpha:0, bgColor:0x000000, estimatedBytes:820000, onFail:_imageFailHandler}) 

Link to post
Share on other sites

here is a simple equation for centerting one object in relation to another object:

 

 

objectToBeCenterd.x = ((referenceObject.width - objectToBeCentered.width)/2 ) + referenceObect.x;

 

imagine you have a simple box mc on the stage and you want it horizontally centered:

 

mc.x = ((stage.stageWidth-mc.width)/2 ) + stage.x

*in the case of aligning to stage, stage.x isn't really necessary as it will most likely always be 0.

 

 

the above equation assumes that both objects have their registration points set to upper left

 

I don't know how you have re-engineered the example, but hopefully that gives you some idea of how to center one object in relation to another. As long as you know the width of both items it shouldn't be too bad.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×