Comunidad de diseño web y desarrollo en internet online

TIMER en funcion dinamica desde fichero .as

Citar            
MensajeEscrito el 28 Dic 2011 04:01 pm
tengo el fichero de nombre column01p.as en el directorio ./clases con 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.net.*;
   import flash.display.DisplayObject;
   public class column01 extends Sprite
   {
      public function column01()
      {
      var bot07:Sprite=new Sprite();   
      var bot06:Sprite=new Sprite();
      var bot05:Sprite=new Sprite();
      var bot04:Sprite=new Sprite();
      var bot03:Sprite=new Sprite();
      var bot02:Sprite=new Sprite();
      var bot01:Sprite=new Sprite();
      var column:Sprite=new Sprite();
      var cuadre:Sprite=new Sprite();
      var ima07:Sprite=new Sprite();
      var ima06:Sprite=new Sprite();
      var ima05:Sprite=new Sprite();
      var ima04:Sprite=new Sprite();
      var ima03:Sprite=new Sprite();
      var ima02:Sprite=new Sprite();
      var ima01:Sprite=new Sprite();
      var n:int= new int();
////////////////////////////////////////////////sonido
//var snd:Sound = new Sound();
//var req:URLRequest = new URLRequest("./imatges/tira02.jpg");
//snd.load(req);
////////////////////////////////////////////////cuadre
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);

////////////////////////////////////////////////imatge 06
var ContenedorImagen06:Loader = new Loader();
var Imagen06:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen06.load(Imagen06);
ima06.scaleX=100;
ima06.scaleY=0.29;
ima06.x=100;
ima06.y=30;
ima06.addChild(ContenedorImagen06);
////////////////////////////////////////////////imatge 07
var ContenedorImagen07:Loader = new Loader();
var Imagen07:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen07.load(Imagen07);
ima07.scaleX=100;
ima07.scaleY=0.29;
ima07.x=100;
ima07.y=30;
ima07.addChild(ContenedorImagen07);
////////////////////////////////////////////////imatge 05
var ContenedorImagen05:Loader = new Loader();
var Imagen05:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen05.load(Imagen05);
ima05.scaleX=100;
ima05.scaleY=0.29;
ima05.x=100;
ima05.y=30;
ima05.addChild(ContenedorImagen05);
////////////////////////////////////////////////imatge 04
var ContenedorImagen04:Loader = new Loader();
var Imagen04:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen04.load(Imagen04);
ima04.scaleX=100;
ima04.scaleY=0.29;
ima04.x=100;
ima04.y=30;
ima04.addChild(ContenedorImagen04);
////////////////////////////////////////////////imatge 03
var ContenedorImagen03:Loader = new Loader();
var Imagen03:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen03.load(Imagen03);
ima03.scaleX=100;
ima03.scaleY=0.29;
ima03.x=100;
ima03.y=30;
ima03.addChild(ContenedorImagen03);
////////////////////////////////////////////////imatge 02
var ContenedorImagen02:Loader = new Loader();
var Imagen02:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen02.load(Imagen02);
ima02.scaleX=100;
ima02.scaleY=0.29;
ima02.x=100;
ima02.y=30;
ima02.addChild(ContenedorImagen02);
////////////////////////////////////////////////imatge01
var ContenedorImagen01:Loader = new Loader();
var Imagen01:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen01.load(Imagen01);
ima01.scaleX=100;
ima01.scaleY=0.29;
ima01.x=100;
ima01.y=30;
ima01.addChild(ContenedorImagen01);

////////////////////////////////////////////////format texte
var formato:TextFormat = new TextFormat ();
formato.align="center";
formato.size=12;
formato.bold=true;
//formato.font="Courier New";
formato.color=0xFFFFFF;
/////////////////////////////////////////////texte07
var texto07:TextField = new TextField();
texto07.autoSize= TextFieldAutoSize.CENTER;
texto07.defaultTextFormat = formato;
texto07.text="Publicidad";
texto07.border=false;
texto07.selectable=false;
texto07.x=120;
texto07.y=31;
/////////////////////////////////////////////texte06
var texto06:TextField = new TextField();
texto06.autoSize= TextFieldAutoSize.CENTER;
texto06.defaultTextFormat = formato;
texto06.text="Aviso legal";
texto06.border=false;
texto06.selectable=false;
texto06.x=120;
texto06.y=31;
/////////////////////////////////////////////texte05
var texto05:TextField = new TextField();
texto05.autoSize= TextFieldAutoSize.CENTER;
texto05.defaultTextFormat = formato;
texto05.text="Acerca de...";
texto05.border=false;
texto05.selectable=false;
texto05.x=120;
texto05.y=31;
/////////////////////////////////////////////texte04
var texto04:TextField = new TextField();
texto04.autoSize= TextFieldAutoSize.CENTER;
texto04.defaultTextFormat = formato;
texto04.text="Contacto";
texto04.border=false;
texto04.selectable=false;
texto04.x=124;
texto04.y=31;
/////////////////////////////////////////////texte03
var texto03:TextField = new TextField();
texto03.autoSize= TextFieldAutoSize.CENTER;
texto03.defaultTextFormat = formato;
texto03.text="Ayuda";
texto03.border=false;
texto03.selectable=false;
texto03.x=130;
texto03.y=31;
/////////////////////////////////////////////texte02
var texto02:TextField = new TextField();
texto02.autoSize= TextFieldAutoSize.CENTER;
texto02.defaultTextFormat = formato;
texto02.text="Actualizaciones";
texto02.border=false;
texto02.selectable=false;
texto02.x=107;
texto02.y=31;
/////////////////////////////////////////////texte01
var texto01:TextField = new TextField();
texto01.autoSize= TextFieldAutoSize.CENTER;
texto01.defaultTextFormat = formato;
texto01.text="Inicio";
texto01.border=false;
texto01.selectable=false;
texto01.x=132;
texto01.y=31;
/////////////////////////////////////////////Timers bot01

var tempo:Timer= new Timer(30);
tempo.addEventListener(TimerEvent.TIMER,centesim);
bot01.addEventListener(MouseEvent.ROLL_OVER, funcio01);
function funcio01 (e:Event){
   cuadre.scaleX=100;
    cuadre.scaleY=1.87;
   tempo.start();
   tempu.reset();
////snd.play();
   
}
function centesim (event:TimerEvent):int{
   n=bot01.y;
   if(bot01.y<3){
   bot01.y+=1;
   bot07.y+=8;
   bot02.y+=15;
   bot03.y+=22;
   bot04.y+=29;
   bot05.y+=36;
   bot06.y+=43;
   }
   if(bot01.y>=3){
      tempo.stop();
      tempo.reset();
      bot01.y=3;
      }
   return n;
   }
var tempu:Timer= new Timer(30);
tempu.addEventListener(TimerEvent.TIMER,centesimu);
column.addEventListener(MouseEvent.ROLL_OUT, funcio01u);
function funcio01u (e:Event){
   cuadre.scaleX=100;
    cuadre.scaleY=1.87;
   tempu.start();
   tempo.reset();
}
function centesimu (event:TimerEvent):int{
   n=bot01.y;
   if(bot01.y>0){
   bot01.y-=1;
   bot07.y-=8;
   bot02.y-=15;
   bot03.y-=22;
   bot04.y-=29;
   bot05.y-=36;
   bot06.y-=43;
   }
   if(bot01.y<=0){
      tempu.stop();
      tempu.reset();
      bot01.y=0;
   }
   return n;
   }
////////////////////////////////////////////////////////////alphas
bot07.addEventListener(MouseEvent.ROLL_OVER, alpha07v);
function alpha07v (e:Event):void{
   bot07.alpha=1;
}
bot07.addEventListener(MouseEvent.ROLL_OUT, alpha07u);
function alpha07u (e:Event):void{
   bot07.alpha=0.85;
}
bot02.addEventListener(MouseEvent.ROLL_OVER, alpha02v);
function alpha02v (e:Event):void{
   bot02.alpha=1;
   }
bot02.addEventListener(MouseEvent.ROLL_OUT, alpha02u);
function alpha02u (e:Event):void{
   bot02.alpha=0.85;
   }
bot03.addEventListener(MouseEvent.ROLL_OVER, alpha03v);
function alpha03v (e:Event):void{
   bot03.alpha=1;
   }
bot03.addEventListener(MouseEvent.ROLL_OUT, alpha03u);
function alpha03u (e:Event):void{
   
   bot03.alpha=0.85;
   }
bot04.addEventListener(MouseEvent.ROLL_OVER, alpha04v);
function alpha04v (e:Event):void{
   bot04.alpha=1;
   }
bot04.addEventListener(MouseEvent.ROLL_OUT, alpha04u);
function alpha04u (e:Event):void{
   bot04.alpha=0.85;
   }
bot05.addEventListener(MouseEvent.ROLL_OVER, alpha05v);
function alpha05v (e:Event):void{
   bot05.alpha=1;
   }
bot05.addEventListener(MouseEvent.ROLL_OUT, alpha05u);
function alpha05u (e:Event):void{
   bot05.alpha=0.85;
   }
bot06.addEventListener(MouseEvent.ROLL_OVER, alpha06v);
function alpha06v (e:Event):void{
   bot06.alpha=1;
}
bot06.addEventListener(MouseEvent.ROLL_OUT, alpha06u);
function alpha06u (e:Event):void{
   bot06.alpha=0.85;
}

////////////////////////////////////////////////////////////links
bot01.addEventListener(MouseEvent.CLICK,linkopen01);
function linkopen01 (e:Event):void {
   navigateToURL(new URLRequest("http://www.soloingenieria.net"));
}
bot02.addEventListener(MouseEvent.CLICK,linkopen02);
function linkopen02 (e:Event):void {
   navigateToURL(new URLRequest("http://www.soloingenieria.net/content/view/12/27/"));
}
bot03.addEventListener(MouseEvent.CLICK,linkopen03);
function linkopen03 (e:Event):void {
   navigateToURL(new URLRequest("http://www.soloingenieria.net/content/view/13/28/"));
}
bot04.addEventListener(MouseEvent.CLICK,linkopen04);
function linkopen04 (e:Event):void {
   navigateToURL(new URLRequest("http://www.soloingenieria.net/component/option,com_contact/Itemid,55/"));
}
bot05.addEventListener(MouseEvent.CLICK,linkopen05);
function linkopen05 (e:Event):void {
   navigateToURL(new URLRequest("http://www.soloingenieria.net/content/view/98/50/"));
}
bot06.addEventListener(MouseEvent.CLICK,linkopen06);
function linkopen06 (e:Event):void {
   navigateToURL(new URLRequest("http://www.soloingenieria.net/content/view/14/29/"));
}
bot07.addEventListener(MouseEvent.CLICK,linkopen07);
function linkopen07 (e:Event):void {
   navigateToURL(new URLRequest("http://www.soloingenieria.net/content/view/123/133/"));
}
////////////////////////////////////////////////////////////capes   
cuadre.alpha=0;
column.addChild(cuadre);
bot06.addChild(ima06);
bot06.addChild(texto06);
bot06.alpha=0.85;
column.addChild(bot06);
bot05.addChild(ima05);
bot05.addChild(texto05);
bot05.alpha=0.85;
column.addChild(bot05);
bot04.addChild(ima04);
bot04.addChild(texto04);
bot04.alpha=0.85;
column.addChild(bot04);
bot03.addChild(ima03);
bot03.addChild(texto03);
bot03.alpha=0.85;
column.addChild(bot03);
bot02.addChild(ima02);
bot02.addChild(texto02);
bot02.alpha=0.85;
column.addChild(bot02);
bot07.addChild(ima07);
bot07.addChild(texto07);
bot07.alpha=0.85;
column.addChild(bot07);
bot01.addChild(ima01);
bot01.addChild(texto01);
bot01.alpha=1;
column.addChild(bot01);   
addChild(column);
         
            
   }
         
   }
}
y luego creo un fla en el directorio ./ por decirlo de alguna manera con el siguiente codigo

Código :

import clases.*;
var auk:column01= new column01();
addChild(auk);
desde aki todo funciona a la perfeccion y la columna menu funciona correctamente con el timer creado, ahora bien imaginemos que queremos hacer lo mismo pero como si fuera una clase dinamica, imaginemos que solo quiero cambiar la variable sprite bot01 simplemente para ver si funciona por lo que todo lo que sea bot01 pasaria a ser this['bot'+1] o que es lo mismo crear una variable var tt:uint=1; y poner this['bot'+tt]=new Sprite; evidentemente la clase tendria que indicar que es dinamica y la funcion tambien
por lo que me quedaria una cosa similar a esto

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
   {
      public dynamic function column01p()
      {
      var tempu:Timer= new Timer(30);
      var tempo:Timer= new Timer(30);


      var bot07:Sprite=new Sprite();   
      var bot06:Sprite=new Sprite();
      var bot05:Sprite=new Sprite();
      var bot04:Sprite=new Sprite();
      var bot03:Sprite=new Sprite();
      var bot02:Sprite=new Sprite();
      
      var tt:uint=1;
      this['bota'+1]=new Sprite;
      var column:Sprite=new Sprite();
      var cuadre:Sprite=new Sprite();
      var ima07:Sprite=new Sprite();
      var ima06:Sprite=new Sprite();
      var ima05:Sprite=new Sprite();
      var ima04:Sprite=new Sprite();
      var ima03:Sprite=new Sprite();
      var ima02:Sprite=new Sprite();
      var ima01:Sprite=new Sprite();
      var n:int= new int();
////////////////////////////////////////////////sonido
//var snd:Sound = new Sound();
//var req:URLRequest = new URLRequest("./imatges/tira02.jpg");
//snd.load(req);
////////////////////////////////////////////////cuadre
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);

////////////////////////////////////////////////imatge 06
var ContenedorImagen06:Loader = new Loader();
var Imagen06:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen06.load(Imagen06);
ima06.scaleX=100;
ima06.scaleY=0.29;
ima06.x=100;
ima06.y=30;
ima06.addChild(ContenedorImagen06);
////////////////////////////////////////////////imatge 07
var ContenedorImagen07:Loader = new Loader();
var Imagen07:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen07.load(Imagen07);
ima07.scaleX=100;
ima07.scaleY=0.29;
ima07.x=100;
ima07.y=30;
ima07.addChild(ContenedorImagen07);
////////////////////////////////////////////////imatge 05
var ContenedorImagen05:Loader = new Loader();
var Imagen05:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen05.load(Imagen05);
ima05.scaleX=100;
ima05.scaleY=0.29;
ima05.x=100;
ima05.y=30;
ima05.addChild(ContenedorImagen05);
////////////////////////////////////////////////imatge 04
var ContenedorImagen04:Loader = new Loader();
var Imagen04:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen04.load(Imagen04);
ima04.scaleX=100;
ima04.scaleY=0.29;
ima04.x=100;
ima04.y=30;
ima04.addChild(ContenedorImagen04);
////////////////////////////////////////////////imatge 03
var ContenedorImagen03:Loader = new Loader();
var Imagen03:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen03.load(Imagen03);
ima03.scaleX=100;
ima03.scaleY=0.29;
ima03.x=100;
ima03.y=30;
ima03.addChild(ContenedorImagen03);
////////////////////////////////////////////////imatge 02
var ContenedorImagen02:Loader = new Loader();
var Imagen02:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen02.load(Imagen02);
ima02.scaleX=100;
ima02.scaleY=0.29;
ima02.x=100;
ima02.y=30;
ima02.addChild(ContenedorImagen02);
////////////////////////////////////////////////imatge01
var ContenedorImagen01:Loader = new Loader();
var Imagen01:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen01.load(Imagen01);
ima01.scaleX=100;
ima01.scaleY=0.29;
ima01.x=100;
ima01.y=30;
ima01.addChild(ContenedorImagen01);

////////////////////////////////////////////////format texte
var formato:TextFormat = new TextFormat ();
formato.align="center";
formato.size=12;
formato.bold=true;
//formato.font="Courier New";
formato.color=0xFFFFFF;
/////////////////////////////////////////////texte07
var texto07:TextField = new TextField();
texto07.autoSize= TextFieldAutoSize.CENTER;
texto07.defaultTextFormat = formato;
texto07.text="Publicidad";
texto07.border=false;
texto07.selectable=false;
texto07.x=120;
texto07.y=31;
/////////////////////////////////////////////texte06
var texto06:TextField = new TextField();
texto06.autoSize= TextFieldAutoSize.CENTER;
texto06.defaultTextFormat = formato;
texto06.text="Aviso legal";
texto06.border=false;
texto06.selectable=false;
texto06.x=120;
texto06.y=31;
/////////////////////////////////////////////texte05
var texto05:TextField = new TextField();
texto05.autoSize= TextFieldAutoSize.CENTER;
texto05.defaultTextFormat = formato;
texto05.text="Acerca de...";
texto05.border=false;
texto05.selectable=false;
texto05.x=120;
texto05.y=31;
/////////////////////////////////////////////texte04
var texto04:TextField = new TextField();
texto04.autoSize= TextFieldAutoSize.CENTER;
texto04.defaultTextFormat = formato;
texto04.text="Contacto";
texto04.border=false;
texto04.selectable=false;
texto04.x=124;
texto04.y=31;
/////////////////////////////////////////////texte03
var texto03:TextField = new TextField();
texto03.autoSize= TextFieldAutoSize.CENTER;
texto03.defaultTextFormat = formato;
texto03.text="Ayuda";
texto03.border=false;
texto03.selectable=false;
texto03.x=130;
texto03.y=31;
/////////////////////////////////////////////texte02
var texto02:TextField = new TextField();
texto02.autoSize= TextFieldAutoSize.CENTER;
texto02.defaultTextFormat = formato;
texto02.text="Actualizaciones";
texto02.border=false;
texto02.selectable=false;
texto02.x=107;
texto02.y=31;
/////////////////////////////////////////////texte01
var texto01:TextField = new TextField();
texto01.autoSize= TextFieldAutoSize.CENTER;
texto01.defaultTextFormat = formato;
texto01.text="Inicio";
texto01.border=false;
texto01.selectable=false;
texto01.x=132;
texto01.y=31;
/////////////////////////////////////////////Timers this['bota'+1]


tempo.addEventListener(TimerEvent.TIMER,centesim);
this['bota'+1].addEventListener(MouseEvent.ROLL_OVER, funcio01);
function funcio01 (e:Event){
   cuadre.scaleX=100;
    cuadre.scaleY=1.87;
   tempo.start();
   tempu.reset();
////snd.play();
   
}
function centesim (event:TimerEvent):int{
   
   n=this['bota'+1].y;
   if(this['bota'+1].y<3){
   this['bota'+1].y+=1;
   bot07.y+=8;
   bot02.y+=15;
   bot03.y+=22;
   bot04.y+=29;
   bot05.y+=36;
   bot06.y+=43;
   }
   if(this['bota'+1].y>=3){
      tempo.stop();
      tempo.reset();
      this['bota'+1].y=3;
      }
   return n;
   }

tempu.addEventListener(TimerEvent.TIMER,centesimu);
column.addEventListener(MouseEvent.ROLL_OUT, funcio01u);
function funcio01u (e:Event){
   cuadre.scaleX=100;
    cuadre.scaleY=1.87;
   tempu.start();
   tempo.reset();
}
function centesimu (event:TimerEvent):int{
   n=this['bota'+1].y;
   if(this['bota'+1].y>0){
   this['bota'+1].y-=1;
   bot07.y-=8;
   bot02.y-=15;
   bot03.y-=22;
   bot04.y-=29;
   bot05.y-=36;
   bot06.y-=43;
   }
   if(this['bota'+1].y<=0){
      tempu.stop();
      tempu.reset();
      this['bota'+1].y=0;
   }
   return n;
   }
////////////////////////////////////////////////////////////alphas
bot07.addEventListener(MouseEvent.ROLL_OVER, alpha07v);
function alpha07v (e:Event):void{
   bot07.alpha=1;
}
bot07.addEventListener(MouseEvent.ROLL_OUT, alpha07u);
function alpha07u (e:Event):void{
   bot07.alpha=0.85;
}
bot02.addEventListener(MouseEvent.ROLL_OVER, alpha02v);
function alpha02v (e:Event):void{
   bot02.alpha=1;
   }
bot02.addEventListener(MouseEvent.ROLL_OUT, alpha02u);
function alpha02u (e:Event):void{
   bot02.alpha=0.85;
   }
bot03.addEventListener(MouseEvent.ROLL_OVER, alpha03v);
function alpha03v (e:Event):void{
   bot03.alpha=1;
   }
bot03.addEventListener(MouseEvent.ROLL_OUT, alpha03u);
function alpha03u (e:Event):void{
   
   bot03.alpha=0.85;
   }
bot04.addEventListener(MouseEvent.ROLL_OVER, alpha04v);
function alpha04v (e:Event):void{
   bot04.alpha=1;
   }
bot04.addEventListener(MouseEvent.ROLL_OUT, alpha04u);
function alpha04u (e:Event):void{
   bot04.alpha=0.85;
   }
bot05.addEventListener(MouseEvent.ROLL_OVER, alpha05v);
function alpha05v (e:Event):void{
   bot05.alpha=1;
   }
bot05.addEventListener(MouseEvent.ROLL_OUT, alpha05u);
function alpha05u (e:Event):void{
   bot05.alpha=0.85;
   }
bot06.addEventListener(MouseEvent.ROLL_OVER, alpha06v);
function alpha06v (e:Event):void{
   bot06.alpha=1;
}
bot06.addEventListener(MouseEvent.ROLL_OUT, alpha06u);
function alpha06u (e:Event):void{
   bot06.alpha=0.85;
}

////////////////////////////////////////////////////////////links
this['bota'+1].addEventListener(MouseEvent.CLICK,linkopen01);
function linkopen01 (e:Event):void {
   navigateToURL(new URLRequest("http://www.soloingenieria.net"));
}
bot02.addEventListener(MouseEvent.CLICK,linkopen02);
function linkopen02 (e:Event):void {
   navigateToURL(new 

URLRequest("http://www.soloingenieria.net/content/view/12/27/"));
}
bot03.addEventListener(MouseEvent.CLICK,linkopen03);
function linkopen03 (e:Event):void {
   navigateToURL(new 

URLRequest("http://www.soloingenieria.net/content/view/13/28/"));
}
bot04.addEventListener(MouseEvent.CLICK,linkopen04);
function linkopen04 (e:Event):void {
   navigateToURL(new 

URLRequest("http://www.soloingenieria.net/component/option,com_contact/Itemid

,55/"));
}
bot05.addEventListener(MouseEvent.CLICK,linkopen05);
function linkopen05 (e:Event):void {
   navigateToURL(new 

URLRequest("http://www.soloingenieria.net/content/view/98/50/"));
}
bot06.addEventListener(MouseEvent.CLICK,linkopen06);
function linkopen06 (e:Event):void {
   navigateToURL(new 

URLRequest("http://www.soloingenieria.net/content/view/14/29/"));
}
bot07.addEventListener(MouseEvent.CLICK,linkopen07);
function linkopen07 (e:Event):void {
   navigateToURL(new 

URLRequest("http://www.soloingenieria.net/content/view/123/133/"));
}
////////////////////////////////////////////////////////////capes   
cuadre.alpha=0;
column.addChild(cuadre);
bot06.addChild(ima06);
bot06.addChild(texto06);
bot06.alpha=0.85;
column.addChild(bot06);
bot05.addChild(ima05);
bot05.addChild(texto05);
bot05.alpha=0.85;
column.addChild(bot05);
bot04.addChild(ima04);
bot04.addChild(texto04);
bot04.alpha=0.85;
column.addChild(bot04);
bot03.addChild(ima03);
bot03.addChild(texto03);
bot03.alpha=0.85;
column.addChild(bot03);
bot02.addChild(ima02);
bot02.addChild(texto02);
bot02.alpha=0.85;
column.addChild(bot02);
bot07.addChild(ima07);
bot07.addChild(texto07);
bot07.alpha=0.85;
column.addChild(bot07);
this['bota'+1].addChild(ima01);
this['bota'+1].addChild(texto01);
this['bota'+1].alpha=1;
column.addChild(this['bota'+1]);   
addChild(column);
         
            
   }
         
   }
}
Esta comprobado como en otras clases que cree que la sintaxis es la correcta, peroooooo me da el siguiente error en el output

Código :

TypeError: Error #1010: Un término no está definido y no tiene propiedades.
   at MethodInfo-4()
   at flash.utils::Timer/_timerDispatch()
   at flash.utils::Timer/tick()

por lo que deduzco que el problema lo tengo en la zona de los timers porlo que pruebo si las funciones de los eventos timer tendrian que ser dinamicas tambien.

Por aukun

Claber

200 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 28 Dic 2011 04:10 pm
los eventos tendria que ponerlos dentro de la funcion dynamica column01p y las funciones de los timers hacerlas publicas pero no necesariamente dinamicas si me dais un patron a seguir, y gracias de antemano por leerme.

Por aukun

Claber

200 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 28 Dic 2011 04:35 pm
La solucion al problema es la siguiente la variable dinamica debe estar dentro de la funcion column01p, mientras que las otras variables deben estar dentro de la clase column y fuera de la funcion dinamica column01p, y las funciones en las que se ve involucrada la variable dinamica deben ser publicas y dinamicas mientras que las funciones en las que modifican varialbes no dinamicas pueden encontrarse dentro de la funcion column01p quedando el codigo de esta manera

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 bot07:Sprite=new Sprite();   
      var bot06:Sprite=new Sprite();
      var bot05:Sprite=new Sprite();
      var bot04:Sprite=new Sprite();
      var bot03:Sprite=new Sprite();
      var bot02:Sprite=new Sprite();
      var column:Sprite=new Sprite();
      var cuadre:Sprite=new Sprite();
      var ima07:Sprite=new Sprite();
      var ima06:Sprite=new Sprite();
      var ima05:Sprite=new Sprite();
      var ima04:Sprite=new Sprite();
      var ima03:Sprite=new Sprite();
      var ima02:Sprite=new Sprite();
      var ima01:Sprite=new Sprite();
      var n:int= new int();
      public dynamic function column01p()
      {
      this['bota'+1]=new Sprite();
////////////////////////////////////////////////sonido
//var snd:Sound = new Sound();
//var req:URLRequest = new URLRequest("./imatges/tira02.jpg");
//snd.load(req);
////////////////////////////////////////////////cuadre
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);

////////////////////////////////////////////////imatge 06
var ContenedorImagen06:Loader = new Loader();
var Imagen06:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen06.load(Imagen06);
ima06.scaleX=100;
ima06.scaleY=0.29;
ima06.x=100;
ima06.y=30;
ima06.addChild(ContenedorImagen06);
////////////////////////////////////////////////imatge 07
var ContenedorImagen07:Loader = new Loader();
var Imagen07:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen07.load(Imagen07);
ima07.scaleX=100;
ima07.scaleY=0.29;
ima07.x=100;
ima07.y=30;
ima07.addChild(ContenedorImagen07);
////////////////////////////////////////////////imatge 05
var ContenedorImagen05:Loader = new Loader();
var Imagen05:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen05.load(Imagen05);
ima05.scaleX=100;
ima05.scaleY=0.29;
ima05.x=100;
ima05.y=30;
ima05.addChild(ContenedorImagen05);
////////////////////////////////////////////////imatge 04
var ContenedorImagen04:Loader = new Loader();
var Imagen04:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen04.load(Imagen04);
ima04.scaleX=100;
ima04.scaleY=0.29;
ima04.x=100;
ima04.y=30;
ima04.addChild(ContenedorImagen04);
////////////////////////////////////////////////imatge 03
var ContenedorImagen03:Loader = new Loader();
var Imagen03:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen03.load(Imagen03);
ima03.scaleX=100;
ima03.scaleY=0.29;
ima03.x=100;
ima03.y=30;
ima03.addChild(ContenedorImagen03);
////////////////////////////////////////////////imatge 02
var ContenedorImagen02:Loader = new Loader();
var Imagen02:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen02.load(Imagen02);
ima02.scaleX=100;
ima02.scaleY=0.29;
ima02.x=100;
ima02.y=30;
ima02.addChild(ContenedorImagen02);
////////////////////////////////////////////////imatge01
var ContenedorImagen01:Loader = new Loader();
var Imagen01:URLRequest=new URLRequest("./imatges/tira02.jpg");
ContenedorImagen01.load(Imagen01);
ima01.scaleX=100;
ima01.scaleY=0.29;
ima01.x=100;
ima01.y=30;
ima01.addChild(ContenedorImagen01);

////////////////////////////////////////////////format texte
var formato:TextFormat = new TextFormat ();
formato.align="center";
formato.size=12;
formato.bold=true;
//formato.font="Courier New";
formato.color=0xFFFFFF;
/////////////////////////////////////////////texte07
var texto07:TextField = new TextField();
texto07.autoSize= TextFieldAutoSize.CENTER;
texto07.defaultTextFormat = formato;
texto07.text="Publicidad";
texto07.border=false;
texto07.selectable=false;
texto07.x=120;
texto07.y=31;
/////////////////////////////////////////////texte06
var texto06:TextField = new TextField();
texto06.autoSize= TextFieldAutoSize.CENTER;
texto06.defaultTextFormat = formato;
texto06.text="Aviso legal";
texto06.border=false;
texto06.selectable=false;
texto06.x=120;
texto06.y=31;
/////////////////////////////////////////////texte05
var texto05:TextField = new TextField();
texto05.autoSize= TextFieldAutoSize.CENTER;
texto05.defaultTextFormat = formato;
texto05.text="Acerca de...";
texto05.border=false;
texto05.selectable=false;
texto05.x=120;
texto05.y=31;
/////////////////////////////////////////////texte04
var texto04:TextField = new TextField();
texto04.autoSize= TextFieldAutoSize.CENTER;
texto04.defaultTextFormat = formato;
texto04.text="Contacto";
texto04.border=false;
texto04.selectable=false;
texto04.x=124;
texto04.y=31;
/////////////////////////////////////////////texte03
var texto03:TextField = new TextField();
texto03.autoSize= TextFieldAutoSize.CENTER;
texto03.defaultTextFormat = formato;
texto03.text="Ayuda";
texto03.border=false;
texto03.selectable=false;
texto03.x=130;
texto03.y=31;
/////////////////////////////////////////////texte02
var texto02:TextField = new TextField();
texto02.autoSize= TextFieldAutoSize.CENTER;
texto02.defaultTextFormat = formato;
texto02.text="Actualizaciones";
texto02.border=false;
texto02.selectable=false;
texto02.x=107;
texto02.y=31;
/////////////////////////////////////////////texte01
var texto01:TextField = new TextField();
texto01.autoSize= TextFieldAutoSize.CENTER;
texto01.defaultTextFormat = formato;
texto01.text="Inicio";
texto01.border=false;
texto01.selectable=false;
texto01.x=132;
texto01.y=31;
/////////////////////////////////////////////Timers this['bota'+1]


tempo.addEventListener(TimerEvent.TIMER,centesim);
this['bota'+1].addEventListener(MouseEvent.ROLL_OVER, funcio01);



tempu.addEventListener(TimerEvent.TIMER,centesimu);
column.addEventListener(MouseEvent.ROLL_OUT, funcio01u);
function funcio01u (e:Event){
   cuadre.scaleX=100;
    cuadre.scaleY=1.87;
   tempu.start();
   tempo.reset();
}

////////////////////////////////////////////////////////////alphas
bot07.addEventListener(MouseEvent.ROLL_OVER, alpha07v);
function alpha07v (e:Event):void{
   bot07.alpha=1;
}
bot07.addEventListener(MouseEvent.ROLL_OUT, alpha07u);
function alpha07u (e:Event):void{
   bot07.alpha=0.85;
}
bot02.addEventListener(MouseEvent.ROLL_OVER, alpha02v);
function alpha02v (e:Event):void{
   bot02.alpha=1;
   }
bot02.addEventListener(MouseEvent.ROLL_OUT, alpha02u);
function alpha02u (e:Event):void{
   bot02.alpha=0.85;
   }
bot03.addEventListener(MouseEvent.ROLL_OVER, alpha03v);
function alpha03v (e:Event):void{
   bot03.alpha=1;
   }
bot03.addEventListener(MouseEvent.ROLL_OUT, alpha03u);
function alpha03u (e:Event):void{
   
   bot03.alpha=0.85;
   }
bot04.addEventListener(MouseEvent.ROLL_OVER, alpha04v);
function alpha04v (e:Event):void{
   bot04.alpha=1;
   }
bot04.addEventListener(MouseEvent.ROLL_OUT, alpha04u);
function alpha04u (e:Event):void{
   bot04.alpha=0.85;
   }
bot05.addEventListener(MouseEvent.ROLL_OVER, alpha05v);
function alpha05v (e:Event):void{
   bot05.alpha=1;
   }
bot05.addEventListener(MouseEvent.ROLL_OUT, alpha05u);
function alpha05u (e:Event):void{
   bot05.alpha=0.85;
   }
bot06.addEventListener(MouseEvent.ROLL_OVER, alpha06v);
function alpha06v (e:Event):void{
   bot06.alpha=1;
}
bot06.addEventListener(MouseEvent.ROLL_OUT, alpha06u);
function alpha06u (e:Event):void{
   bot06.alpha=0.85;
}

////////////////////////////////////////////////////////////links
this['bota'+1].addEventListener(MouseEvent.CLICK,linkopen01);

bot02.addEventListener(MouseEvent.CLICK,linkopen02);
function linkopen02 (e:Event):void {
   navigateToURL(new 

URLRequest("http://www.soloingenieria.net/content/view/12/27/"));
}
bot03.addEventListener(MouseEvent.CLICK,linkopen03);
function linkopen03 (e:Event):void {
   navigateToURL(new 

URLRequest("http://www.soloingenieria.net/content/view/13/28/"));
}
bot04.addEventListener(MouseEvent.CLICK,linkopen04);
function linkopen04 (e:Event):void {
   navigateToURL(new 

URLRequest("http://www.soloingenieria.net/component/option,com_contact/Itemid

,55/"));
}
bot05.addEventListener(MouseEvent.CLICK,linkopen05);
function linkopen05 (e:Event):void {
   navigateToURL(new 

URLRequest("http://www.soloingenieria.net/content/view/98/50/"));
}
bot06.addEventListener(MouseEvent.CLICK,linkopen06);
function linkopen06 (e:Event):void {
   navigateToURL(new 

URLRequest("http://www.soloingenieria.net/content/view/14/29/"));
}
bot07.addEventListener(MouseEvent.CLICK,linkopen07);
function linkopen07 (e:Event):void {
   navigateToURL(new 

URLRequest("http://www.soloingenieria.net/content/view/123/133/"));
}
////////////////////////////////////////////////////////////capes   
cuadre.alpha=0;
column.addChild(cuadre);
bot06.addChild(ima06);
bot06.addChild(texto06);
bot06.alpha=0.85;
column.addChild(bot06);
bot05.addChild(ima05);
bot05.addChild(texto05);
bot05.alpha=0.85;
column.addChild(bot05);
bot04.addChild(ima04);
bot04.addChild(texto04);
bot04.alpha=0.85;
column.addChild(bot04);
bot03.addChild(ima03);
bot03.addChild(texto03);
bot03.alpha=0.85;
column.addChild(bot03);
bot02.addChild(ima02);
bot02.addChild(texto02);
bot02.alpha=0.85;
column.addChild(bot02);
bot07.addChild(ima07);
bot07.addChild(texto07);
bot07.alpha=0.85;
column.addChild(bot07);
this['bota'+1].addChild(ima01);
this['bota'+1].addChild(texto01);
this['bota'+1].alpha=1;
column.addChild(this['bota'+1]);   
addChild(column);
               
   }
public dynamic function funcio01 (e:Event){
   cuadre.scaleX=100;
    cuadre.scaleY=1.87;
   tempo.start();
   tempu.reset();
////snd.play();
   
}
public dynamic function centesim (event:TimerEvent):int{
   
   n=this['bota'+1].y;
   if(this['bota'+1].y<3){
   this['bota'+1].y+=1;
   bot07.y+=8;
   bot02.y+=15;
   bot03.y+=22;
   bot04.y+=29;
   bot05.y+=36;
   bot06.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;
   bot07.y-=8;
   bot02.y-=15;
   bot03.y-=22;
   bot04.y-=29;
   bot05.y-=36;
   bot06.y-=43;
   }
   if(this['bota'+1].y<=0){
      tempu.stop();
      tempu.reset();
      this['bota'+1].y=0;
   }
   return n;
   }
public dynamic function linkopen01 (e:Event):void {
   navigateToURL(new URLRequest("http://www.soloingenieria.net"));
}      
   }
}

por lo visto es importante que las funciones en las que se ven implicadas directamente variables dinamicas han de ser declaradas como funciones publicas y dinamicas por lo que deben estar fuera de la funcion principal column01p, las variables no dinamicas deben declararse o definirse fuera de la funcion principal(le digo principal, que esla column01p porque tiene el mismo nombre que la clase, pero no tiene que ser asi) y por lo visto tambien la variable dinamica debe ser definida dentro de la funcion principal, ahora desenvolupare esto mismo pero con todas las variable dynamicas a ver como queda el codigo reducido.

Por aukun

Claber

200 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 29 Dic 2011 02:29 pm
aqui una reduccion de codigo de un 400%

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();
      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;}
for(t=2;t<=7;t++){this['bota'+t].addEventListener(MouseEvent.ROLL_OVER, alpha07v);
this['bota'+t].addEventListener(MouseEvent.ROLL_OUT, alpha07u);}
tempo.addEventListener(TimerEvent.TIMER,centesim);
this['bota'+1].addEventListener(MouseEvent.ROLL_OVER, funcio01);
tempu.addEventListener(TimerEvent.TIMER,centesimu);
column.addEventListener(MouseEvent.ROLL_OUT, funcio01u);
this['bota'+1].addEventListener(MouseEvent.CLICK,linkopen01);
this['bota'+2].addEventListener(MouseEvent.CLICK,linkopen02);
this['bota'+3].addEventListener(MouseEvent.CLICK,linkopen03);
this['bota'+4].addEventListener(MouseEvent.CLICK,linkopen04);
this['bota'+5].addEventListener(MouseEvent.CLICK,linkopen05);
this['bota'+6].addEventListener(MouseEvent.CLICK,linkopen06);
this['bota'+7].addEventListener(MouseEvent.CLICK,linkopen07);
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 linkopen01 (e:Event):void {navigateToURL(new URLRequest("htp://www.soloingenieria.net"));}   
public dynamic function linkopen02 (e:Event):void {navigateToURL(new URLRequest("htp://www.soloingenieria.net/content/view/12/27/"));}
public dynamic function linkopen03 (e:Event):void {navigateToURL(new URLRequest("htp://www.soloingenieria.net/content/view/13/28/"));}
public dynamic function linkopen04 (e:Event):void {navigateToURL(new URLRequest("htp://www.soloingenieria.net/component/option,com_contact/Itemid,55/"));}
public dynamic function linkopen05 (e:Event):void {navigateToURL(new URLRequest("htp://www.soloingenieria.net/content/view/98/50/"));}
public dynamic function linkopen06 (e:Event):void {navigateToURL(new URLRequest("htp://www.soloingenieria.net/content/view/14/29/"));}
public dynamic function linkopen07 (e:Event):void {navigateToURL(new URLRequest("htp://www.soloingenieria.net/content/view/123/133/"));}
public dynamic function alpha07v (e:Event):void{this['bota'+e.target.name.substr(4)].alpha=1;}
public dynamic function alpha07u (e:Event):void{this['bota'+e.target.name.substr(4)].alpha=0.85;}
   }
}

Por aukun

Claber

200 de clabLevel



Genero:Masculino  

firefox

 

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