Well that's what I thought, but when I change this:

event.target.startDrag();

to this:

event.target.startDrag(false, 10, 0, myCanvas.width, myCanvas.height);

I get the following error:

ArgumentError: Error #1063: Argument count mismatch on 
flash.display::Sprite/startDrag(). Expected 0, got 5.


--- In flexcoders@yahoogroups.com, "iilsley" <[EMAIL PROTECTED]> wrote:
>
> startDrag allows you to specify 'bounds' .. 
> 
> 
> ---------
> startDrag(lockCenter:Boolean = false, bounds:Rectangle = null):void
> 
> 
> Parameters
>       lockCenter:Boolean (default = false) — Specifies whether the
> draggable sprite is locked to the center of the mouse position 
(true),
> or locked to the point where the user first clicked the sprite 
(false).
>  
>       bounds:Rectangle (default = null) — Value relative to the 
coordinates
> of the Sprite's parent that specify a constraint rectangle for the 
Sprite.
> ----------
> 
> --- In flexcoders@yahoogroups.com, "jmfillman" <jmfillman@> wrote:
> >
> > How do I set a boundary that draggable objects must stay within? 
Take 
> > the example below, if you click and drag the button to the left, 
you 
> > can drag it so it's x value is negative. Further, I want to 
constrain 
> > the mouse movements to the visible portion of the canvas, while 
the 
> > button is being dragged. I've played around with setting the 
button's 
> > x value to 0 if it ever goes below 0, but as you continue to move 
the 
> > button to the left away from the canvas, that stops working once 
the 
> > mouse pointer is not over the button, and then you have a 
floating 
> > button that you cannot drop. Please help!
> > 
> > <?xml version="1.0"?>
> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
> > backgroundColor="white" initialize="initApp();">
> >     <mx:Script>
> >         <![CDATA[
> >         import mx.core.DragSource;
> >         import mx.managers.DragManager;
> >         import mx.controls.Button;
> >         
> >         private function initApp():void{
> >             var myButton:Button = new Button;
> >             myButton.width = 100;
> >             myButton.height = 50;
> >             myButton.y = 150;
> >             myButton.label = "Test Button";
> >             myButton.addEventListener(MouseEvent.MOUSE_MOVE, 
> > doDrag, false, 0, true);
> >             myButton.addEventListener(MouseEvent.MOUSE_UP, 
> > endDrag, false, 0, true);
> >             myCanvas.addChild(myButton);
> >         }
> >         private function doDrag(event:MouseEvent):void {
> >                     if (event.currentTarget is Button && 
> > event.buttonDown == true) {
> >                             var dragTarget:Button = 
> > event.currentTarget as Button;
> >                             dragTarget.setFocus();
> >                             event.target.startDrag();
> >                     }
> >         }
> >         private function endDrag(event:MouseEvent):void {
> >             event.target.stopDrag();        
> >         }
> >          ]]>
> >     </mx:Script>
> >      <mx:Canvas id="myCanvas" width="200"  height="300" 
> > backgroundColor="#FFFFFF" borderStyle="solid" 
> > verticalScrollPolicy="on" horizontalScrollPolicy="off">
> >         <mx:HRule x="0" y="700"/>
> >     </mx:Canvas>
> > </mx:Application>
> >
>


Reply via email to