Comunidad de diseño web y desarrollo en internet online

porque el MouseEvent.ROLLOVER me hace un taget diferente al MouseCLICK

Citar            
MensajeEscrito el 02 Ene 2012 09:27 am
tengo el siguiente codigo

Código :

package clases{
   import flash.utils.*;import flash.text.*;import flash.events.*;import flash.display.Sprite;import flash.display.Loader;
   import flash.display.*;   import flash.net.*;import flash.display.DisplayObject;
   public dynamic class column01p extends Sprite{
      var tempu:Timer= new Timer(30);var tempo:Timer= new Timer(30);var k:uint;var t:uint;var m:uint;
      var column:Sprite=new Sprite();var cuadre:Sprite=new Sprite();var ff:uint;var n:int= new int();var j:uint;
      var ar01j:Array=new Array('','htp://www.soloingenieria.net','htp://www.soloingenieria.net/content/view/12/27/',
'htp://www.soloingenieria.net/content/view/13/28/','htp://www.soloingenieria.net/component/option,com_contact/Itemid,55/',
'htp://www.soloingenieria.net/content/view/98/50/','htp://www.soloingenieria.net/content/view/14/29/',
'htp://www.soloingenieria.net/content/view/123/133/');
      public dynamic function column01p(){      
var Contenedorcuadre:Loader = new Loader();var cuadreurl:URLRequest=new URLRequest("./imatges/tira02.jpg");
Contenedorcuadre.load(cuadreurl);cuadre.scaleX=0;cuadre.scaleY=0;cuadre.x=100;cuadre.y=33;cuadre.addChild(Contenedorcuadre);
var formato:TextFormat = new TextFormat ();formato.align="center";formato.size=12;formato.bold=true;formato.color=0xFFFFFF;
var ar01:Array=new Array('','Publicidad','Aviso legal','Acerca de...','Contacto','Ayuda','Actualizaciones','Inicio');
var ar01x:Array=new Array(0,120,120,120,124,130,107,132);var ar01a:Array=new Array(0,0.85,0.85,0.85,0.85,0.85,0.85,0.85);

for(k=1;k<=7;k++){this['bota'+k]=new Sprite;this['imma'+k]=new Sprite;this['cima'+k]=new Loader;this['imag'+k]=new URLRequest("./imatges/tira02.jpg");
this['cima'+k].load(this['imag'+k]);this['imma'+k].scaleX=100;this['imma'+k].scaleY=0.29;this['imma'+k].x=100;this['imma'+k].y=30;
this['imma'+k].addChild(this['cima'+k]);this['text'+k]=new TextField;this['text'+k].autoSize= TextFieldAutoSize.CENTER;
this['text'+k].defaultTextFormat = formato;this['text'+k].text=ar01[k];this['text'+k].x=ar01x[k];this['text'+k].border=false;
this['text'+k].selectable=false;this['text'+k].y=31;this['bota'+k].name='bota'+k;this['imma'+k].name='im'+k}
for(t=2;t<=7;t++){this['bota'+t].addEventListener(MouseEvent.ROLL_OVER, alpha07v);this['bota'+t].addEventListener(MouseEvent.ROLL_OUT, alpha07u);
this['bota'+t].addEventListener(MouseEvent.CLICK,linkopen01);}
tempo.addEventListener(TimerEvent.TIMER,centesim);
this['bota'+1].addEventListener(MouseEvent.ROLL_OVER, funcio01);
tempu.addEventListener(TimerEvent.TIMER,centesimu);
column.addEventListener(MouseEvent.ROLL_OUT, funcio01u);
cuadre.alpha=0;column.addChild(cuadre);
for(m=1;m<=7;m++){ff=(8-m);ff=(8-m);this['bota'+ff].addChild(this['imma'+ff]);this['bota'+ff].addChild(this['text'+ff]);this['bota'+ff].alpha=0.85;
column.addChild(this['bota'+ff]);}
addChild(column);}
public dynamic function funcio01 (e:Event){cuadre.scaleX=100;cuadre.scaleY=1.87;tempo.start();tempu.reset();}
public dynamic function funcio01u (e:Event){cuadre.scaleX=100;cuadre.scaleY=1.87;tempu.start();tempo.reset();}
public dynamic function centesim (event:TimerEvent):int{n=this['bota'+1].y;
   if(this['bota'+1].y<3){this['bota'+1].y+=1;this['bota'+7].y+=8;this['bota'+2].y+=15;this['bota'+3].y+=22;this['bota'+4].y+=29;this['bota'+5].y+=36;this['bota'+6].y+=43;}
   if(this['bota'+1].y>=3){tempo.stop();tempo.reset();this['bota'+1].y=3;}return n;}
public dynamic function centesimu (event:TimerEvent):int{n=this['bota'+1].y;
   if(this['bota'+1].y>0){this['bota'+1].y-=1;this['bota'+7].y-=8;this['bota'+2].y-=15;this['bota'+3].y-=22;this['bota'+4].y-=29;this['bota'+5].y-=36;this['bota'+6].y-=43;}
   if(this['bota'+1].y<=0){tempu.stop();tempu.reset();this['bota'+1].y=0;}return n;}
   
public dynamic function alpha07v (e:MouseEvent):void{this['bota'+e.target.name.substr(4)].alpha=1;trace(e.target.name.substr(0));}
public dynamic function alpha07u (e:MouseEvent):void{this['bota'+e.target.name.substr(4)].alpha=0.85;trace(e.target.name.substr(0));}
public dynamic function linkopen01 (e:MouseEvent):void {trace (e.target.name.substr(0));}
el trace de las funciones alpha07v alpha07u me lo hace bien consiguiendo bota1, bota2, bota3 ... en cambio al hacer click y por tanto al realizar la funcion linkopen01 el trace no me da los nombres corespondientes a this['bota'+k].name='bota' + k; porque sucede eso; el trace que me genera en los botones al hacer CLICK es Instance10, Instance25,Instance30, es como si al hacer CLICK los nombres 'e.target.name' que cree en los sprites se me convirtieran en otros, de antemano muchas gracias por leerme, y si existiera alguna manera de solucionar eso, mientras tanto voy probando.

Por aukun

Claber

200 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 02 Ene 2012 09:53 am
curiosamente quise saber a que objeto me estaba aplicando el MOUSEEVENT.CLICK cosa que yo tenia puesto ese evento en this['bota'+j].addEventListener , asi que puse el trace(e.target) --> cual fue mi sorpresa que en el output me estaba poniendo objeto TEXTFIELD, asi que los nombres de Instance10, instance 20 .... corresponden a los objetos textfield (tiene pinta a bug de AS3) XDDD asi que puse lo siguiente this['text'+k].name='im'+k; y en el trace de la funcion linkopen01 que esta unida el evento click puse e.target.name.substr(2) y ahora funciona a la perfeccion, gracias por si me leyo alguien, simplemente es curioso que pase eso cuando el objeto en el que tengo aplicado el evento click corresponde a los sprites this['bota'+j] y no a this['text'+k] supongo que como estos deben estar ocupados porque el evento ROLLOVER esta funcionando cuando tengo el mouse encima el boton, me traslada el evento click a los textsfields this['text'+k] y no a los sprites this['bota'+j] a los cuales tengo añadidos esos eventos click, simplemente curioso, lo solucione, pero es una rareza XDD.

Por aukun

Claber

200 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 02 Ene 2012 10:00 am
perdonad olvide de poner el codigo aki lo teneis

Código :

package clases{
   import flash.utils.*;import flash.text.*;import flash.events.*;import flash.display.Sprite;import flash.display.Loader;
   import flash.display.*;   import flash.net.*;import flash.display.DisplayObject;
   public dynamic class column01p extends Sprite{
      var tempu:Timer= new Timer(30);var tempo:Timer= new Timer(30);var k:uint;var t:uint;var m:uint;
      var column:Sprite=new Sprite();var cuadre:Sprite=new Sprite();var ff:uint;var n:int= new int();var j:uint;
      var ar01j:Array=new Array('','htp://www.soloingenieria.net','htp://www.soloingenieria.net/content/view/12/27/',
'htp://www.soloingenieria.net/content/view/13/28/','htp://www.soloingenieria.net/component/option,com_contact/Itemid,55/',
'htp://www.soloingenieria.net/content/view/98/50/','htp://www.soloingenieria.net/content/view/14/29/',
'htp://www.soloingenieria.net/content/view/123/133/');
      public dynamic function column01p(){      
var Contenedorcuadre:Loader = new Loader();var cuadreurl:URLRequest=new URLRequest("./imatges/tira02.jpg");
Contenedorcuadre.load(cuadreurl);cuadre.scaleX=0;cuadre.scaleY=0;cuadre.x=100;cuadre.y=33;cuadre.addChild(Contenedorcuadre);
var formato:TextFormat = new TextFormat ();formato.align="center";formato.size=12;formato.bold=true;formato.color=0xFFFFFF;
var ar01:Array=new Array('','Publicidad','Aviso legal','Acerca de...','Contacto','Ayuda','Actualizaciones','Inicio');
var ar01x:Array=new Array(0,120,120,120,124,130,107,132);var ar01a:Array=new Array(0,0.85,0.85,0.85,0.85,0.85,0.85,0.85);
for(k=1;k<=7;k++){this['bota'+k]=new Sprite;this['imma'+k]=new Sprite;this['cima'+k]=new Loader;this['imag'+k]=new URLRequest("./imatges/tira02.jpg");
this['cima'+k].load(this['imag'+k]);this['imma'+k].scaleX=100;this['imma'+k].scaleY=0.29;this['imma'+k].x=100;this['imma'+k].y=30;
this['imma'+k].addChild(this['cima'+k]);this['text'+k]=new TextField;this['text'+k].autoSize= TextFieldAutoSize.CENTER;
this['text'+k].defaultTextFormat = formato;this['text'+k].text=ar01[k];this['text'+k].x=ar01x[k];this['text'+k].border=false;
this['text'+k].selectable=false;this['text'+k].y=31;this['bota'+k].name='bota'+k;this['text'+k].name='im'+k;}
for(t=2;t<=7;t++){this['bota'+t].addEventListener(MouseEvent.ROLL_OVER, alpha07v);this['bota'+t].addEventListener(MouseEvent.ROLL_OUT, alpha07u);
this['bota'+t].addEventListener(MouseEvent.CLICK,linkopen01);}
tempo.addEventListener(TimerEvent.TIMER,centesim);
this['bota'+1].addEventListener(MouseEvent.ROLL_OVER, funcio01);
tempu.addEventListener(TimerEvent.TIMER,centesimu);
column.addEventListener(MouseEvent.ROLL_OUT, funcio01u);
cuadre.alpha=0;column.addChild(cuadre);
for(m=1;m<=7;m++){ff=(8-m);ff=(8-m);this['bota'+ff].addChild(this['imma'+ff]);this['bota'+ff].addChild(this['text'+ff]);this['bota'+ff].alpha=0.85;
column.addChild(this['bota'+ff]);}
addChild(column);}
public dynamic function funcio01 (e:Event){cuadre.scaleX=100;cuadre.scaleY=1.87;tempo.start();tempu.reset();}
public dynamic function funcio01u (e:Event){cuadre.scaleX=100;cuadre.scaleY=1.87;tempu.start();tempo.reset();}
public dynamic function centesim (event:TimerEvent):int{n=this['bota'+1].y;
   if(this['bota'+1].y<3){this['bota'+1].y+=1;this['bota'+7].y+=8;this['bota'+2].y+=15;this['bota'+3].y+=22;this['bota'+4].y+=29;this['bota'+5].y+=36;this['bota'+6].y+=43;}
   if(this['bota'+1].y>=3){tempo.stop();tempo.reset();this['bota'+1].y=3;}return n;}
public dynamic function centesimu (event:TimerEvent):int{n=this['bota'+1].y;
   if(this['bota'+1].y>0){this['bota'+1].y-=1;this['bota'+7].y-=8;this['bota'+2].y-=15;this['bota'+3].y-=22;this['bota'+4].y-=29;this['bota'+5].y-=36;this['bota'+6].y-=43;}
   if(this['bota'+1].y<=0){tempu.stop();tempu.reset();this['bota'+1].y=0;}return n;}
public dynamic function alpha07v (e:MouseEvent):void{this['bota'+e.target.name.substr(4)].alpha=1;trace(e.target.name.substr(0));}
public dynamic function alpha07u (e:MouseEvent):void{this['bota'+e.target.name.substr(4)].alpha=0.85;trace(e.target.name.substr(0));}
public dynamic function linkopen01 (e:MouseEvent):void {navigateToURL(new URLRequest(ar01j[e.target.name.substr(2)]));}
   }
}
aunque lo solucione, no entiendo porque el evento click es aplicado en el los textfield y no en los sprites ????? ES un BUG XD???

Por aukun

Claber

200 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 03 Ene 2012 04:03 am
tenes setear la propiedad mouseChildren a false, para que el boton reciba el click y no el texto u objetos que contenga.


mouseChildren : Boolean
Determina si los elementos secundarios del objeto están habilitados para ratón.


Saludos


eXe

Por exekiel21

Claber

164 de clabLevel



Genero:Masculino  

programador

firefox
Citar            
MensajeEscrito el 03 Ene 2012 07:09 am
ahora mismo lo pruebo a ver que tal os digo algo

Por aukun

Claber

200 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 03 Ene 2012 07:40 am
perfecto gracias el codigo quedaria asi

Código :

package clases{
import flash.utils.*;
import flash.text.*;
import flash.events.*;
import flash.display.Sprite;
import flash.display.Loader;
import flash.display.*;   
import flash.net.*;
import flash.display.DisplayObject;
public dynamic class column01p extends Sprite{
var tempu:Timer= new Timer(30);var tempo:Timer= new Timer(30);var k:uint;
var t:uint;var m:uint;var column:Sprite=new Sprite();var cuadre:Sprite=new Sprite();
var ff:uint;var n:int= new int();var j:uint;
var ar01j:Array=new Array('','http://www.soloingenieria.net','http://www.soloingenieria.net/content/view/12/27/',
'http://www.soloingenieria.net/content/view/13/28/',
'http://www.soloingenieria.net/component/option,com_contact/Itemid,55/',
'http://www.soloingenieria.net/content/view/98/50/',
'http://www.soloingenieria.net/content/view/14/29/',
'http://www.soloingenieria.net/content/view/123/133/');
public dynamic function column01p(){
var Contenedorcuadre:Loader = new Loader();var cuadreurl:URLRequest=new URLRequest("./imatges/tira02.jpg");
Contenedorcuadre.load(cuadreurl);cuadre.scaleX=0;cuadre.scaleY=0;cuadre.x=100;cuadre.y=33;
cuadre.addChild(Contenedorcuadre);var formato:TextFormat = new TextFormat ();formato.align="center";
formato.size=12;formato.bold=true;formato.color=0xFFFFFF;
var ar01:Array=new Array('','Entra com','Usuari','Grup','Empresa','Tutor','Creador','Anònim');
var ar01x:Array=new Array(0,124,130,135,126,133,127,127);
var ar01a:Array=new Array(0,0.85,0.85,0.85,0.85,0.85,0.85,0.85);
var ar01i:Array=new Array('','','','','','','','');
var formato1:TextFormat = new TextFormat ();formato1.align="justify";
formato1.size=18;formato1.italic=true;formato1.color=0x6882b5;

for(k=1;k<=7;k++){
this['bota'+k]=new Sprite;this['imma'+k]=new Sprite;this['cima'+k]=new Loader;
this['imag'+k]=new URLRequest("./imatges/tira02.jpg");this['cima'+k].load(this['imag'+k]);
this['imma'+k].scaleX=100;this['imma'+k].scaleY=0.29;
this['imma'+k].x=100;this['imma'+k].y=30;this['imma'+k].addChild(this['cima'+k]);
this['text'+k]=new TextField;this['text'+k].autoSize= TextFieldAutoSize.CENTER;
this['text'+k].defaultTextFormat = formato;this['text'+k].text=ar01[k];
this['text'+k].x=ar01x[k];this['text'+k].border=false;this['text'+k].selectable=false;
this['text'+k].y=31;this['bota'+k].name='bota'+k;//this['text'+k].name='im'+k;
this['text1'+k]=new TextField;this['text1'+k].wordWrap=true;this['text1'+k].width=288;
this['text1'+k].autoSize= TextFieldAutoSize.LEFT;this['text1'+k].defaultTextFormat = formato1;
this['text1'+k].text=ar01i[k];this['text1'+k].x=ar01x[k];this['text1'+k].border=true;
this['text1'+k].borderColor=0xf8f8f8;this['text1'+k].alpha=0.8;
this['text1'+k].selectable=false;this['text1'+k].y=52;this['text1'+k].x=510;
}

for(t=2;t<=7;t++){
                                       this['bota'+t].mouseChildren=false;

this['bota'+t].addEventListener(MouseEvent.ROLL_OVER, alpha07v);
this['bota'+t].addEventListener(MouseEvent.ROLL_OUT, alpha07u);
this['bota'+t].addEventListener(MouseEvent.CLICK,linkopen01);
}
tempo.addEventListener(TimerEvent.TIMER,centesim);
this['bota'+1].addEventListener(MouseEvent.ROLL_OVER, funcio01);
tempu.addEventListener(TimerEvent.TIMER,centesimu);
column.addEventListener(MouseEvent.ROLL_OUT, funcio01u);
cuadre.alpha=0;column.addChild(cuadre);

for(m=1;m<=7;m++){
ff=(8-m);ff=(8-m);this['bota'+ff].addChild(this['imma'+ff]);this['bota'+ff].addChild(this['text'+ff]);
this['bota'+ff].alpha=0.85;column.addChild(this['bota'+ff]);}addChild(column);
}
public dynamic function funcio01 (e:Event){cuadre.scaleX=100;cuadre.scaleY=1.87;tempo.start();tempu.reset();}
public dynamic function funcio01u (e:Event){cuadre.scaleX=100;cuadre.scaleY=1.87;tempu.start();tempo.reset();}
public dynamic function centesim (event:TimerEvent):int{n=this['bota'+1].y;if(this['bota'+1].y<3){this['bota'+1].y+=1;this['bota'+7].y+=8;this['bota'+2].y+=15;this['bota'+3].y+=22;this['bota'+4].y+=29;this['bota'+5].y+=36;this['bota'+6].y+=43;}if(this['bota'+1].y>=3){tempo.stop();tempo.reset();this['bota'+1].y=3;}return n;}
public dynamic function centesimu (event:TimerEvent):int{n=this['bota'+1].y;if(this['bota'+1].y>0){this['bota'+1].y-=1;this['bota'+7].y-=8;this['bota'+2].y-=15;this['bota'+3].y-=22;this['bota'+4].y-=29;this['bota'+5].y-=36;this['bota'+6].y-=43;}if(this['bota'+1].y<=0){tempu.stop();tempu.reset();this['bota'+1].y=0;}return n;}
public dynamic function alpha07v (e:MouseEvent):void{this['bota'+e.target.name.substr(4)].alpha=1;addChild(this['text1'+e.target.name.substr(4)]);}
public dynamic function alpha07u (e:MouseEvent):void{this['bota'+e.target.name.substr(4)].alpha=0.85;removeChild(this['text1'+e.target.name.substr(4)]);}
public dynamic function linkopen01 (e:MouseEvent):void {trace (e.target.name.substr(4));}}}

Por aukun

Claber

200 de clabLevel



Genero:Masculino  

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.