PDA

View Full Version : boundary checking in as3


steve88
09-09-2008, 12:49 PM
Hi All,

I need help bad.
I got a image which I can scale up or down, and i want to be able to pan the image around within a view area dimension with boundary checking. The panning around can also be done via key presses as while, so I couldn't really use the startDrag functoin

The image itself in dynamically loaded and dynamically centered as well

The problem i am getting is that the image size is always going to be a different proportion to that of the view area.

Basically I want something like the photoshop style navigation mechanism without the interface.

Can someone help me out urgently.


thanks

lordofduct
09-09-2008, 01:40 PM
well you can find the scaled width by multiplying the scale by it's dimensions.

Or the easiest is to just use the "DisplayObject.getBounds()" method. It returns a Rectangle of the boundaries of the object with respect to how it looks in the displayList at that moment. Just take that and compare that rect to the boundary rect you want to keep it in.

I'm assuming your object is a DisplayObject (it's in the DisplayList) so it's gonna have the getBounds() method.

steve88
09-09-2008, 02:09 PM
I did a quick test with some like this

if(_container.getBounds(this).y >g.getBounds(this).y){
_ypos = 10;
}
_container.y = _ypos

the problem i am getting is that it doesn't fix the position, and when it does i can't drag the image back up again;

Any ideas