Archive Page 18

Stage.onResize - Menú escalable.

Este script genera un menú horizontal cuyos botones se ajustan el ancho del navegador.

Ver ejemplo

Actionscript:
  1. Stage.scaleMode = 'noScale';
  2. Stage.align = 'TL';
  3. formato = new TextFormat();
  4. formato.font = 'verdana';
  5. formato.size = 10;
  6. function makeBoton(tmp_mc, ancho, largo, p, col, label) {
  7.     var tm_mc = tmp_mc.createEmptyMovieClip("tempo" + p, p);
  8.     tm_mc.beginFill(col);
  9.     tm_mc.lineTo(0, 0);
  10.     tm_mc.lineTo(0 + ancho, 0);
  11.     tm_mc.lineTo(0 + ancho, 0 + largo);
  12.     tm_mc.lineTo(0, 0 + largo);
  13.     tm_mc.lineTo(0, 0);
  14.     tm_mc.createTextField("label_txt", p + 100, 5, 0, 0, 0);
  15.     tm_mc.label_txt.text = label;
  16.     tm_mc.label_txt.autoSize = true;
  17.     tm_mc.label_txt.setTextFormat(formato);
  18.     tm_mc.onRollOver = function() {
  19.         this.label_txt.textColor = 0xffffff;
  20.     };
  21.     tm_mc.onRollOut = function() {
  22.         this.label_txt.textColor = 0x000000;
  23.     };
  24.     tm_mc.onRelease = function() {
  25.     };
  26.     return tm_mc;
  27. }
  28. function init() {
  29.     Stage.scaleMode = "noScale";
  30.     liste = new Object();
  31.     liste.onResize = size;
  32.     Stage.addListener(liste);
  33.     clips = [];
  34.     basex = 0;
  35.     menu_mc = createEmptyMovieClip("menu", 1);
  36.     label_array = ["Uno", "Dos", "Tres", "Cuatro", "Cinco", "Seis"];
  37.     for (var i = 0; i <label_array.length; i++) {
  38.         var clip = makeBoton(menu_mc, 70, 15, i, "0xc1c1c1", label_array[i]);
  39.         clip._x = basex;
  40.         clips.push(clip);
  41.         basex += clip._width;
  42.     }
  43.     size();
  44. }
  45. function size() {
  46.     basex = 0;
  47.     tamanio = Stage.width / label_array.length;
  48.     for (var i = 0; i <clips.length; i++) {
  49.         clips[i]._x = basex;
  50.         basex += tamanio + 2;
  51.         clips[i]._width = tamanio;
  52.     }
  53. }
  54. init();

Publicar

Dimensiones: Porcentaje
Escalar:No escalar

Descarga Resizable Menu.zip

Resizable Menu.zip se ha descargado 280 veces.

 Votes | Average: 0 out of 5 Votes | Average: 0 out of 5 Votes | Average: 0 out of 5 Votes | Average: 0 out of 5 Votes | Average: 0 out of 5 (No hay votos todavia.)
Loading ... Loading ...

Pasar parámetros desde HTML a Flash

Pasar parámetros desde HTML a flash

Para pasar parámetros desde HTMl a una película de flash, se adjunta una variable concatenada al nombre de la película .swf. de la siguiente forma:

HTML:
  1. <!--para Internet explorer-->
  2. <param name="movie" value="mipeliculaflash.swf?mi_var=Hola mundo">
  3. <!-- para fireFox y otros navegadores-->
  4. src="mipeliculaflash.swf?mi_var=Hola mundo"

La película flash recoge la variable de la siguiente forma:

Actionscript:
  1. trace(_root.mi_var);

Ejemplo
Para cargar una película de flash pasándo parámetros, copia el siguiente HTML substituyendo los valores movie,src y parámetros por lo tuyos:

HTML:
  1. classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″
  2. codebase="http://download.macromedia.com/pub/shockwave
  3. /cabs/flash/swflash.cab#version=6,0,29,0width="200″   height="100>
  4. <param name="movie" value="mipeliculaflash.swf?mi_var=Hola mundo">
  5. <param name="quality" value="high">
  6. <embed src="mipeliculaflash.swf?mi_var=Hola mundo"
  7. quality="high"
  8. pluginspage="http://www.macromedia.com/go/getflashplayer"
  9. type="application/x-shockwave-flash"
  10. width="200″ height="100>
  11. </embed>
  12. </object>

Pasar parámetros desde HTML a flash usando el parámetro FlashVars

Otro método válido consiste en usar FlashVars:

HTML:
  1. <!-- Para explorer -->
  2. <param name="FlashVars" value="mi_var=Hola  Mundo">
  3. <!-- Para firefox y otros navegadores -->
  4. src="mipeliculaflash.swf" FlashVars="mi_var=Hola Mundo"

Ejemplo
Para cargar una película de flash pasándo FlashVars, copia el siguiente HTML substituyendo los valores movie,src y parámetros por lo tuyos:

HTML:
  1. classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″
  2. codebase="http://download.macromedia.com/pub/shockwave
  3. /cabs/flash/swflash.cab#version=6,0,29,0width="200″   height="100>
  4. <param name="movie" value="mipeliculaflash.swf">
  5. <param name="FlashVars" value="mi_var=Hola  Mundo">
  6. <param name="quality" value="high">
  7. <embed src="mipeliculaflash.swf"
  8. FlashVars="mi_var=Hola Mundo"
  9. quality="high"
  10. pluginspage="http://www.macromedia.com/go/getflashplayer"
  11. type="application/x-shockwave-flash"
  12. width="200″ height="100>
  13. </embed>
  14. </object>

2 Votes | Average: 4.5 out of 52 Votes | Average: 4.5 out of 52 Votes | Average: 4.5 out of 52 Votes | Average: 4.5 out of 52 Votes | Average: 4.5 out of 5 (2 votos, promedio: 4.5 sobre 5)
Loading ... Loading ...