Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
Posts: 138
Registered: ‎01-09-2011
My Device: Blackberry Tablet OS
Accepted Solution

Drag an Object

Hello I am trying to give the user an option to drag and drop certain images within a certain 'rectangle'.

 

Here is my code minus the addEventListener calls.

 

 

private function mouseDown(e:MouseEvent):void{
this.startDrag(false,new Rectangle(0,0,999,550));
}
private function mouseUp(e:MouseEvent):void{
this.stopDrag();
}

 When I drag the image it is surpassing the limits of 999x550, why?

 

Have I misunderstood what the bounds parameter of the startDrag function is used for?

 

 

From,
Noah NU
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Drag an Object

What object is the parent of this DisplayObject?  Also, what are the dimensions of this object?  The bounds apparently apply to the top-left corner of the object, not the entire thing.

 

Also, can you confirm that you are trying to allow dragging anywhere on the screen except a 25-pixel region along the right edge, and a 50-pixel region along the bottom?  Or where those intended to account for the size of the object already, and you just want dragging anywhere on the stage?


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 138
Registered: ‎01-09-2011
My Device: Blackberry Tablet OS

Re: Drag an Object

"Also, can you confirm that you are trying to allow dragging anywhere on the screen except a 25-pixel region along the right edge, and a 50-pixel region along the bottom?"

 

Yes.

 

The dimensions of the object vary.

 

It works now. I did not know that is applies to the top left of the object. I assumed that the startDrag function automatically took the objects dimensions into account when applying the bounds.

From,
Noah NU