startDrag()method public function startDrag(lockCenter:Boolean<http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Boolean.html> = false, bounds:Rectangle<http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/geom/Rectangle.html> = null):void<http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/specialTypes.html#void> Parameters lockCenter:Boolean<http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Boolean.html> (default = false) — Specifies whether the draggable sprite is locked to the center of the pointer position (true), or locked to the point where the user first clicked the sprite (false). bounds:Rectangle<http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/geom/Rectangle.html> (default = null) — Value relative to the coordinates of the Sprite's parent that specify a constraint rectangle for the Sprite.
Oq vc precisará fazer é usar o parametro *bounds:Rectangle*. var areaRestrita:Rectangle = new Rectangle(seuCanvas.x, seuCanva.y, seucanvas.w, seucanvas.h); seuElemento.startDrag(false, areaRestrita); Pronto! Só ler a documentação. []'s Em 22 de agosto de 2011 12:00, Principe borodin <[email protected]>escreveu: > nao entendi bem o q vc kis dizer nao > > > http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Sprite.html#startDrag%28%29 > > ate procurei na documentacao e nao achei nada no caso estou usando um > canvas pra limitar o espaço de "trabalho" do usuario... > > On Aug 21, 10:19 pm, Mário Júnior <[email protected]> wrote: > > No próprio método startDrag vc pode passar um Rectangle como argumento > para > > determinar a área de constraints. > > Consulte a documentação oficial desse método q vc achará até código de > > exemplo. > > > > Lembrando q 'startDrag()' e 'stopDrag()' sao herdados do Flash. Outra > forma > > (e talvez até melhor, se pretende usar validações) é usar a classe > > DragManager do Flex SDK. > > > > []'s > > > > Em 21 de agosto de 2011 21:37, Principe borodin > > <[email protected]>escreveu: > > > > > > > > > > > > > > > > > > > > > Eu to querendo criar uma aplicacao onde eu possa usar determinados > > > objetos dentro de um canvas...mas ele nao pode sair do canvas, pois ao > > > lado tera uma "paleta" de ferramentas....eu tentei algo bem simples > > > mas nao foi... > > > > > <?xml version="1.0" encoding="utf-8"?> > > > <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" > > > xmlns:s="library:// > > > ns.adobe.com/flex/spark" > > > xmlns:mx="library:// > > > ns.adobe.com/flex/mx" > > > width="1000" height="600" > > > creationComplete="init()"> > > > <fx:Script> > > > <![CDATA[ > > > import mx.events.DragEvent; > > > import mx.controls.Alert; > > > protected function > > > campo_dragStartHandler(event:DragEvent):void > > > { > > > // TODO Auto-generated method stub > > > > > } > > > private function init():void > > > { > > > > > campo.addEventListener(MouseEvent.MOUSE_DOWN,sg); > > > > > campo.addEventListener(MouseEvent.MOUSE_UP,sgu); > > > } > > > private function sg(event:MouseEvent):void > > > { > > > //Alert.show(event.currentTarget.y); > > > var tam:int = event.currentTarget.width > + > > > event.currentTarget.x; > > > > > if(campo.hitTestObject(canvas)) > > > { > > > event.currentTarget.startDrag(); > > > } > > > } > > > private function sgu(event:MouseEvent):void > > > { > > > > > //Alert.show(event.currentTarget.width+event.currentTarget.x); > > > event.currentTarget.stopDrag(); > > > } > > > > > ]]> > > > </fx:Script> > > > <fx:Declarations> > > > <!-- Place non-visual elements (e.g., services, value > > > objects) here > > > --> > > > </fx:Declarations> > > > <mx:Canvas x="20" y="20" id="canvas" borderVisible="true" > > > borderColor="0x000000" width="700" height="500" > > > > <s:TextInput id="campo"/> > > > </mx:Canvas> > > > </s:WindowedApplication> > > > > > -- > > > Você recebeu esta mensagem porque está inscrito na lista "flexdev" > > > Para enviar uma mensagem, envie um e-mail para > [email protected] > > > Para sair da lista, envie um email em branco para > > > [email protected] > > > Mais opções estão disponíveis emhttp://groups.google.com/group/flexdev > > > > -- > > Mario Juniorhttp://blog.mariojunior.com/ > > @mariojunior > > -- > Você recebeu esta mensagem porque está inscrito na lista "flexdev" > Para enviar uma mensagem, envie um e-mail para [email protected] > Para sair da lista, envie um email em branco para > [email protected] > Mais opções estão disponíveis em http://groups.google.com/group/flexdev > -- Mario Junior http://blog.mariojunior.com/ @mariojunior -- Você recebeu esta mensagem porque está inscrito na lista "flexdev" Para enviar uma mensagem, envie um e-mail para [email protected] Para sair da lista, envie um email em branco para [email protected] Mais opções estão disponíveis em http://groups.google.com/group/flexdev
