Jump to content
GreenSock

Ahrengot

Finding out where AutoFitArea moves your objects

Recommended Posts

Hey!

 

I'm utilizing AutoFitArea in one of my projects, but haven't had a lot of experience working with that particular class yet, and i'm a little confused as to how it works.

 

I've setup the area like this:

_autoFitArea =  new AutoFitArea(this, 0, 0, stage.stageWidth, stage.stageHeight);
_autoFitArea.attach(_background, "proportionalOutside", "center", "center");

 

added a stage.RESIZE listener and in that handler method i do this:

private function onStageResize(e:Event = null):void 
{
_autoFitArea.width = stage.stageWidth;
_autoFitArea.height = stage.stageHeight;
}

 

Everything works as it should, but at some point later in the code i need to do a bitmap.draw() of the _background DisplayObject. And to do that accurately i need the position of _background, but when i read the x and y properties of _background it reports back 0.

 

Reading x/y properties from the AutoFitArea itself reports 0 back as well. Is there any way to get those values, and how come they return 0? Is that how it's supposed to work?

Link to comment
Share on other sites

Tough to say what's going on without seeing your file. It'd be normal for the AutoFitArea to remain at x:0/y:0 unless you specifically change it, but I don't know why the attached object doesn't seem to be moving. I suspect there may be something else going on in your code. If you still need help, please post a sample FLA that demonstrates the issue in as simple a manner as possible (no need to send your production files).

 

For what it's worth, LiquidStage has a LiquidArea class that extends AutoFitArea and automatically resizes itself based on the stage's resizing events. http://www.greensock.com/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.
×