Jump to content
GreenSock

sb12

AutoFitArea in AIR-context: weird problem

Recommended Posts

Hey Jack,

I am currently using your very handy AutoFitArea class in an BasicImage class that has the functionality to show an image (eg Bitmap) in every size you want it to.

It all works like a charm except when starting the thing in AIR:

Some images had incorrect positions (although they should be centered), and I think I pinned the problem down to the fact that the BasicImage class was not on stage when using the AutoFitArea internally. Is there any possibility that this could cause misbehavior (only in AIR context!)? Unfortunately, I have no time at the moment to strip my classes to the point where you could reproduce the error...

 

Thanks in advance

Matthias

Link to comment
Share on other sites

Yeah, in order for AutoFitArea to work, your objects must be in the display list. It relies on target.getBounds(target.parent) which won't work if the object has no parent :) Is there a reason you cannot put your objects on the stage before attaching them to AutoFitArea?

 

Also keep in mind that you can call the update() method anytime on AutoFitArea to force an update (like when your objects are added to the display list).

Link to comment
Share on other sites

The interesting thing is that the child had a parent when attaching it, but was not on the displaylist (no connection to stage). I used update() together with Event.ADDED_TO_STAGE to easily eliminate the problem, but still its pretty weird that this is only malfunctioning in the AIR context (btw: Adobe AIR 2, perhaps there are still some bugs around...).

 

Thanks again,

Matthias

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