Pues si la verdad, aquí explica el tema "When you use addEventListener to assign event handlers to listen for events, by default, you are listening for events only within the target and bubbling phases. This means propagating events with the default addEventListener usage will start with the target and then be sent to each parent of that target. If you want a handler to listen for events in the capture phase, for events reaching the parents before reaching the target, you have to specify to addEventListener that you want to use the capture phase by passing true for its third parameter, the useCapture parameter. If you want to listen for events for all phases, you have to use addEventListener twice, once using the default useCapture (false) and again with useCapture set to true."
igualmente no me habia dado cuenta ayer, y el texto que meto en el contenedor si que heredaba los eventos del ratón lo que pasa es que no me sacaba "la manita" del puntero. La cosa es que la propiedad de "buttonMode = true" no me funciona en el textField. Tanto si se la marco al contenedor donde añado el fondo y el texto, como si se la añado al objeto que instancio en el flash, solo le hace caso el shape y no el textField, supongo que es pq el textField no tiene esa propiedad. Pero si el textField tiene comportamiento de botón al ser un interactiveobject pq no tiene propiedades como "buttonMode = true"? será pq es una propiedad que se hereda de DisplayObject y al no heredar de él no la tiene??? bueno gracias Paulo por la ayuda y a ver si alguien me echa un cablecillo aunque sigo investigando. Saludos ----- Original Message ----- From: "Paulo Carvajal" <[EMAIL PROTECTED]> To: "Lista dedicada a Actionscript" <[email protected]> Sent: Thursday, May 17, 2007 6:24 PM Subject: Re: [ASNativos] crear boton con as 3.0 Vas a tener que leer sobre el event bubbling, me temo. Sé que van por ahí los tiros, para que el evento se propague (o no) al los objetos que lo contienen. miBtn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler, true, true);// aqui hay dos paramentros más, me temo Si te enteras bien, me lo cuentas, por favor. Es que ahora no estoy en el curro, a ver si esta noche puedo mirarte algo más concreto, que tenía fichado un ejemplo; Un saludo, Paulo. El día 17/05/07, FlashNativo <[EMAIL PROTECTED]> escribió: > > Hola Paulo gracias por responder. > > La cosa es que si creo un contenedor y en el creo el fondo y encima el > texto: > > > ******************************************************* > package{ > import flash.display.*; > import flash.text.TextField; > public class tipoBoton extends Sprite{ > public function tipoBoton(){ > buttonMode = true > var contenedor:Sprite = new Sprite() > var boton:Shape = createShape(0xff0000); > var txt:TextField = new TextField(); > txt.text = "hola" > boton.x = 100 > boton.y = 100 > txt.x = boton.x+5 > txt.y = boton.y+2 > txt.selectable = false > contenedor.addChild(boton) > contenedor.addChild(txt) > addChild(contenedor) > } > public function createShape(color:uint):Shape{ > var shape:Shape = new Shape(); > shape.graphics.beginFill(color); > shape.graphics.drawRect(0,0,100,20); > shape.graphics.endFill(); > return shape; > > } > } > } > ******************************************************* > > y luego lo instancio en el flash tal que asi: > > ******************************************************* > import flash.events.MouseEvent; > var miBtn:tipoBoton = new tipoBoton() > miBtn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); > > function mouseDownHandler(event:MouseEvent):void { > trace("mouseOutHandler"); > } > addChild(miBtn) > > ******************************************************* > > Solo se comporta como boton el shape y no el texto. Si tengo que hacer un > botón de esta manera tengo que declarar los eventos del ratón tanto del > texto como del fondo de cada botón??? no se no me parece lo suyo esto ta > mal..... > > saludosss > > ----- Original Message ----- > From: "Paulo Carvajal" <[EMAIL PROTECTED]> > To: "Lista dedicada a Actionscript" <[email protected]> > Sent: Thursday, May 17, 2007 1:02 PM > Subject: Re: [ASNativos] crear boton con as 3.0 > > > Aún ando muy verde, pero no te valdría con esto: > > var boton:Shape = createShape(0xff0000); > var txt:TextField = new TextFiled(blabla); > addChild(boton); > boton.addChild(txt); > > Así en bruto y rápido. Y el textfield estaría contenido en el shape, que > no > se si se puede ahora mismo, creo que no, pero mejor hazte un contenedor > que > sea un sprite y se lo metes todo sin anidarlo. > > > > El día 17/05/07, FlashNativo <[EMAIL PROTECTED]> escribió: > > > > Hola quería preguntaros cual es el mejor modo para crear el típico boton > > cuadrado con su texto encima con flash cs3 y as 3.0. > > > > He visto que tanto la clase textField como sprite o textfield etc etc > > tienen los eventos típicos de botón. Claro está todos son subclases de > > interactiveObject. > > La cosa es que como estoy empezando con esto de las listas de > > visualización se me plantean dudas. > > Yo tengo pj una clase que extiendo de shape que me crea un cuadrado no? > > como esta: > > > > package{ > > import flash.display.*; > > public class tipoBoton extends Sprite{ > > public function tipoBoton(){ > > buttonMode = true > > var boton:Shape = createShape(0xff0000); > > boton.x = 100 > > boton.y = 100 > > addChild(boton); > > } > > public function createShape(color:uint):Shape{ > > var shape:Shape = new Shape(); > > shape.graphics.beginFill(color); > > shape.graphics.drawRect(0,0,100,20); > > shape.graphics.endFill(); > > return shape; > > > > } > > } > > } > > > > en el constructor hago el addchild de la shape que creo para mostrarlo > en > > pantalla. ¿como podría hacer para que ese botón contubiera un campo de > > texto?, pk si creo un textField y lo meto tb en la lista de > visualización > > con addchild, serán dos elementos separados no? no serán el mismo > > objeto... > > > > no se si me he explicado a ver si alguien me aclara un poco. > > > > > > Hacias a todos > > ----------------------------------------------------- > > ASNativos > > www.5dms.com > > subscripciones/desubscripciones > > http://asnativos.5dms.com > > ----------------------------------------------------- > > > ----------------------------------------------------- > ASNativos > www.5dms.com > subscripciones/desubscripciones > http://asnativos.5dms.com > ----------------------------------------------------- > > > ----------------------------------------------------- > ASNativos > www.5dms.com > subscripciones/desubscripciones > http://asnativos.5dms.com > ----------------------------------------------------- > ----------------------------------------------------- ASNativos www.5dms.com subscripciones/desubscripciones http://asnativos.5dms.com ----------------------------------------------------- ----------------------------------------------------- ASNativos www.5dms.com subscripciones/desubscripciones http://asnativos.5dms.com -----------------------------------------------------

