Jump to content
Search Community

LiquidStage - MaxWidth + Center pin?

zumajoe test
Moderator Tag

Recommended Posts

I'm having issues with resize and keeping center alignment at the same time... not sure what i'm missing here. I have it set so it can only resize to a max of 1200.

 

I tried mixing both Pin and Resize but i don't get good results. What I want is to just have the content ALWAYS stay centered.

 

alignment.jpg

		
var ls:LiquidStage=new LiquidStage(this.stage,995,900,900,814,1200);
var area:LiquidArea=new LiquidArea(this,50,130,890,356,0x313f19);

area.pinCorners(ls.TOP_LEFT, ls.BOTTOM_RIGHT, false, 1.75, {ease:Quint.easeOut});
//ls.attach(contentHolder, ls.CENTER, false, true, 1.75, {ease:Quint.easeOut});
area.preview=true;
area.attach(contentHolder);

Link to comment
Share on other sites

Yeah, all you'd need to do is position it in the center initially, and then pin it to the CENTER pin with:

 

ls.attach(contentHolder, ls.CENTER, false, true, 1.75, {ease:Quint.easeOut});

 

Keep in mind that when you attach() an object, you're telling it to maintain its relative distance from that PinPoint. So if your object starts out being off-center by 100 pixels and you pin it to the CENTER PinPoint, it will always be 100 pixels away from the center. This is much more flexible that forcing the objects to exactly the center or one of the edges.

 

I bet you just forgot to center your object initially. So, assuming your object's registration point is in its upper left corner, you'd do:

myObject.x = (this.stage.stageWidth - myObject.width) / 2;
myObject.y = (this.stage.stageHeight - myObject.height) / 2;

 

If your object's registration point isn't at the upper left corner, it's slighly more complicated, but totally doable. Let me know if you need that equation.

 

Again, run that code first before attaching the object to LiquidStage.

Link to comment
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.
×
×
  • Create New...