deu certo nao

nem assim...
<?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="700"
height="600">
        <fx:Declarations>
                <!-- Place non-visual elements (e.g., services, value objects) 
here
-->
        </fx:Declarations>
        <fx:Script>
                <![CDATA[

                        import mx.events.DragEvent;
                        import flash.geom.Rectangle;
                        private var area:Rectangle= new
Rectangle(canvas.x,canvas.y,canvas.width,canvas.height);;
                        private function init():void
                        {
                                area = new
Rectangle(canvas.x,canvas.y,canvas.width,canvas.height);
                                
campo.addEventListener(MouseEvent.MOUSE_DOWN,sd);
                                campo.addEventListener(MouseEvent.MOUSE_UP,sot);
                        }
                        private function sd(event:MouseEvent):void
                        {
                                event.currentTarget.startDrag(false,area);
                        }
                        private function sot(event:MouseEvent):void
                        {
                                event.currentTarget.stopDrag();
                        }
                ]]>
        </fx:Script>
        <mx:Canvas id="canvas" x="20" y="20" width="500" height="400">
                <s:TextInput id="campo" x="20" y="20"/>
        </mx:Canvas>
</s:WindowedApplication>

e nem assim...

<?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="700"
height="600">
        <fx:Declarations>
                <!-- Place non-visual elements (e.g., services, value objects) 
here
-->
        </fx:Declarations>
        <fx:Script>
                <![CDATA[

                        import flash.geom.Rectangle;
                        import mx.events.DragEvent;
                        private var area:Rectangle;
                        private function init():void
                        {
                                area = new
Rectangle(canvas.x,canvas.y,canvas.width,canvas.height);
                                
campo.addEventListener(MouseEvent.MOUSE_DOWN,sd);
                                campo.addEventListener(MouseEvent.MOUSE_UP,sot);
                        }
                        private function sd(event:MouseEvent):void
                        {
                                event.currentTarget.startDrag(false,area);
                        }
                        private function sot(event:MouseEvent):void
                        {
                                event.currentTarget.stopDrag();
                        }
                ]]>
        </fx:Script>
        <mx:Canvas id="canvas" x="20" y="20" width="500" height="400">
                <s:TextInput id="campo" x="20" y="20"/>
        </mx:Canvas>
</s:WindowedApplication>




On Aug 22, 12:15 pm, Mário Júnior <juninho...@gmail.com> wrote:
> startDrag()method
> public function
> startDrag(lockCenter:Boolean<http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Bo...>
> =
> false, 
> bounds:Rectangle<http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl...>
> =
> null):void<http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/sp...>
> Parameters
> lockCenter:Boolean<http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Bo...>
> (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/fl...>
> (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
> <principe.boro...@gmail.com>escreveu:
>
>
>
>
>
>
>
>
>
> > nao entendi bem o q vc kis dizer nao
>
> >http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl...
>
> > 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 <juninho...@gmail.com> 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
> > > <principe.boro...@gmail.com>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
> > flexdev@googlegroups.com
> > > > Para sair da lista, envie um email em branco para
> > > > flexdev-unsubscr...@googlegroups.com
> > > > 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 flexdev@googlegroups.com
> > Para sair da lista, envie um email em branco para
> > flexdev-unsubscr...@googlegroups.com
> > 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 flexdev@googlegroups.com
Para sair da lista, envie um email em branco para 
flexdev-unsubscr...@googlegroups.com
Mais opções estão disponíveis em http://groups.google.com/group/flexdev

Responder a