Jump to content
Search Community

Centering an swf while using LiquidStage

el_barto test
Moderator Tag

Recommended Posts

Hi,

 

I'm kind of new to the whole GreenSock classes so you'll have to excuse my knowledge level, but I had a question about using the LiquidStage and LiquidArea classes. Is it possible to dynamically center a display object whilst still using the LiquidStage and Area to resize the display object as and when the user resizes their browser? For example, if you created a simple box which was always dynamically positioned to be in the center of the screen, can it's size still be changed so that when the browser window was resized the box's dimensions would also change in relation to it's original proportion, whilst still remaining in the center of the screen? I haven't got an example to show as of yet as I wanted to see if this was possible before I began. Any help, advice or pointers would be greatly appreciated.

 

Thanks.

Link to comment
Share on other sites

Absolutely. You'd just create a LiquidArea around your object in the center. It would automatically resize when the stage resizes too. So let's assume you build your swf at 500x400 (native size) and put your object "mc" in the center so that it looks perfect when you publish but you want it to resize itself whenever the stage resizes:

 

var ls:LiquidStage = new LiquidStage(this.stage, 500, 400);
var area:LiquidArea = LiquidArea.createAround(mc);

 

There are several other ways to accomplish the same thing, but this is the least amount of code.

Link to comment
Share on other sites

Hi,

 

Thank you very much for getting back to me with a solution to my question! Since my orignal post I went back and read through the documentation that came with the download and managed to get my head around it and made it work, thought my way did involve much more code so I'll remember your way in future.

 

Actually I have run into another problem. I have created another thread (viewtopic.php?f=3&t=4652), but basically it involves the main swf being made really small when published out, either as an swf or and html. I think what could be happening is that I've got a line line of thumbnails running off screen in another swf that it being loaded into my main swf file and that is causing the code to think that the swf's are much wider than they should be when displayed and are scaling everything up or down depending on that overall width and not on the actual visible width of the stage.

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...