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.