Comunidad de diseño web y desarrollo en internet online

Cargar diferentes elementos en boton hecho con AS2

Citar            
MensajeEscrito el 23 Abr 2010 07:46 pm
Hola encontré un tutorial donde se hacen botones dinamicamente con puro codigo AS2, este es el codigo.

Código ActionScript :

import flash.filters.GlowFilter;
import flash.filters.DropShadowFilter;
var labels:Array = ["diseño web", "portfolio", "about me", "photo gallery"];
var messages1:Array = ["http://www.flashexplained.com", "Oh! Another one.", "ActionScript rules.", "ActionScript and ActionScript only!"];
var messages2:Array = ["Don't these buttons look cool?", "The shadow filter gives more realism to the button.", "The shadow also gives the impression as the button is pushed inside the page.", "ActionScript buttons rule."];
var messages3:Array = ["The dark glow around this button's label makes it 3-D like, as it was sticking out.", "Hooray for Flash!", "All these menus were created on the fly!", "Code reusability rules."];
var messages4:Array = ["Click! Click! Click!", "Learn ActionScript and become a Flash wizard!", "I *love* ActionScript!", "OK now, proceed with the tutorial :)"];
var offset:Number = 10;
function createButtons(buttonSeries:Number, color1:Number, color2:Number, color3:Number, color4:Number, lineColor:Number, labelColor:Number, numberOfButtons:Number, posX:Number, posY:Number, labelFilterColor:Number, labelFilterAlpha:Number, labelFilterBlur:Number, labelFilterStrength:Number, applyLabelFilter:Boolean, applyBkgFilter:Boolean) {
   for (var i:Number = 0; i<numberOfButtons; i++) {
      var labelGlow:GlowFilter = new GlowFilter(labelFilterColor, labelFilterAlpha, labelFilterBlur, labelFilterBlur, labelFilterStrength, 3);
      var labelFilters:Array = [labelGlow];
      var buttonShadow:DropShadowFilter = new DropShadowFilter(1, 45, 0x000000, 1, 4, 4, 1, 3);
      var buttonFilters:Array = [buttonShadow];
      var myButton:MovieClip = this.createEmptyMovieClip("myButton"+String(buttonSeries)+String(i), this.getNextHighestDepth());
      myButton._x = offset+(posX*i);
      myButton._y = offset+posY;
      var fillType:String = "linear";
      var colors:Array = [color1, color2, color3, color4];
      var alphas:Array = [100, 100, 100, 100];
      var ratios:Array = [0, 126, 127, 255];
      var matrix:Object = {matrixType:"box", x:0, y:0, w:120, h:30, r:90/180*Math.PI};
      myButton.createEmptyMovieClip("buttonBkg", myButton.getNextHighestDepth());
      myButton.buttonBkg.lineStyle(0, lineColor, 60, true, "none", "square", "round");
      myButton.buttonBkg.beginGradientFill(fillType, colors, alphas, ratios, matrix);
      myButton.buttonBkg.lineTo(120, 0);
      myButton.buttonBkg.lineTo(120, 30);
      myButton.buttonBkg.lineTo(0, 30);
      myButton.buttonBkg.lineTo(0, 0);
      myButton.buttonBkg.endFill();
      var myFormat:TextFormat = new TextFormat();
      myFormat.align = "center";
      myFormat.font = "Tahoma";
      myFormat.size = 13;
      myFormat.color = labelColor;
      myButton.createTextField("labelText", myButton.getNextHighestDepth(), 0, 5, myButton._width, 24);
      myButton.labelText.text = labels[i];
      myButton.labelText.embedFonts = true;
      myButton.labelText.selectable = false;
      myButton.labelText.antiAliasType = "advanced";
      myButton.labelText.setTextFormat(myFormat);
      if (applyLabelFilter) {
         myButton.labelText.filters = labelFilters;
      }
      if (applyBkgFilter) {
         myButton.filters = buttonFilters;
      }
      myButton.onPress = function() {
         var currentArray:Array = eval("messages"+buttonSeries);
//         _parent.mc_cargador.loadMovie("swf/A1.swf");
         var currentButtonNumber:Number = this._name.substr(-1, 1);
         messageDisplay_txt.text = currentArray[currentButtonNumber];
         getURL("http://www.yahoo.com");

      }
   }
}
createButtons(1, 0xFAD4DB, 0xEC748B, 0xC13A59, 0xA81230, 0x820F26, 0xFFFFFF, 4, 135, 10, 0xFFFFFF, .30, 4, 3, true, false);
createButtons(2, 0xCECAF9, 0x8E77EE, 0x5339BD, 0x3216A5, 0x000000, 0xFFFFFF, 4, 135, 80, 0xFFFFFF, .40, 4, 3, false, true);
createButtons(3, 0xFFFFFF, 0xCCCCCC, 0x000000, 0x000000, 0x000000, 0xFFFFFF, 4, 135, 150, 0x000000, .60, 2, 4, true, false);
createButtons(4, 0xFFFFFF, 0xCCCCCC, 0xCCCCCC, 0xFFFFFF, 0x000000, 0x000000, 4, 135, 220, 0xFFFFFF, .30, 4, 3, false, true);



La cuestión es que los botones los genera dinamicamente y por ende no le puedo decir que botón siga un link especifico y si le doy clic a cualquier botón manda a la misma dirección.

Lo que yo necesito es que me cargue un clip de pelicula en un cargador, como lo con un menu hecho con botones normales:

Código ActionScript :

btn_p1.onRelease = function() {
   _parent.mc_cargador.loadMovie("swf/A1.swf");
   
}



¿Cómo puedo indicarle que haga la función loadMovie, a cada uno de los swf?
Yo siento que la clave esta en esta parte del código.

Código ActionScript :

var labels:Array = ["diseño web", "portfolio", "about me", "photo gallery"];
var messages1:Array = ["http://www.flashexplained.com", "Oh! Another one.", "ActionScript rules.", "ActionScript and ActionScript only!"];
var messages2:Array = ["Don't these buttons look cool?", "The shadow filter gives more realism to the button.", "The shadow also gives the impression as the button is pushed inside the page.", "ActionScript buttons rule."];
var messages3:Array = ["The dark glow around this button's label makes it 3-D like, as it was sticking out.", "Hooray for Flash!", "All these menus were created on the fly!", "Code reusability rules."];
var messages4:Array = ["Click! Click! Click!", "Learn ActionScript and become a Flash wizard!", "I *love* ActionScript!", "OK now, proceed with the tutorial :)"];
var offset:Number = 10;


¿Por favor hay alguien que me pudiera orientar?

Saludos y gracias por su tiempo y atención.

Por CLzangelx

5 de clabLevel



 

msie
Citar            
MensajeEscrito el 26 Abr 2010 03:49 pm
Hola nuevamente, traté de poner diferentes direcciones web pero lo unico que pasa es que se abren las 2 o mas paginas al mismo tiempo sin impotar que boton presione. Se que no es mucho problema pero no logro cambiar el comportamiento del script para que me fucione.

Saludos y gracias por la atención.

Por CLzangelx

5 de clabLevel



 

msie

 

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