Comunidad de diseño web y desarrollo en internet online

AS Combinado para CREAR BOTONES desde AS

Citar            
MensajeEscrito el 10 Abr 2007 03:24 pm
Hola amigos, me encuentro en un dilema, encontre este codigo para crear botones de AS y funciona a la perfeccion.

for (var i:Number = 1; i<=10; i++)
{
var num:String = String(i);
generar_boton(this, "bot"+num, 10, i*20, "botón "+num);
}
//--------------------------------------------------------
function generar_boton(ruta:MovieClip, nombre:String, posx:Number, posy:Number, contenido:String)
{
var clip:MovieClip = ruta.createEmptyMovieClip(nombre, ruta.getNextHighestDepth());
clip._x = posx;
clip._y = posy;
clip.createTextField("texto", 1, 0, 0, 100, 20);
clip.texto.text = contenido;
clip.onRelease = function()
{
trace("hola, soy el botón ["+nombre+"] "+contenido);
};
}

Pero lo que quiero es que el texto de los botones sea el que se crea con este codigo, que muestra texto dinamico desde una base de datos:

//
// movieclip.mover(posicion x, posicion y, velocidad);
//

MovieClip.prototype.mover = function( x, y, vel) {
this.onEnterFrame = function() {
this._x += (x-this._x)/vel;
this._y += (y-this._y)/vel;
};
};
///
btn_pa.onRelease = function() {
mapa.mover(118, 20, 4);
};
///
btn_pb.onRelease = function() {
mapa.mover(118, -330, 4);
};


function extraerseccion(seccion) {
myVar = new LoadVars();
myVar.load('http://www.zonadesistema.com/404/lista.php?id='+seccion);
myVar.onLoad = function( success ){
if(success){
alto = 350.0;
nivel = 0;
x = 13.0;
x1 = 800.0;
lineas = 1;
if (myVar.total == "undefined"){
myVar.total = "1";
}

for(this.a=1;this.a<=15;this.a++){
if (lineas <=7) {
createTextField(["Link_"+this.a], nivel,x,alto,300.2,35.3);

nivel = nivel+1;
trace (nivel);
createTextField(["Web_"+this.a], nivel,x1,alto,30.2,17.3);

trace(b);
trace(["Web_"+this.a]);



myformat = new TextFormat();
//myformat.bullet = true;
myformat.color = 0x000000;
myformat.size = 11;
myformat.font = "arial";
myformat.html = true;
myformat.bold = true;

myformat1 = new TextFormat;
myformat1.multiline = true;
myformat1.color = 0xFF0000;
myformat1.size = 11;
myformat1.bold = true;
myformat1.font = "arial";


_root["Tienda_"+this.a].text = myVar["tienda"+this.a];
_root["Tienda_"+this.a].setTextFormat(myformat1);
_root["Web_"+this.a].text = "\""+myVar["web"+this.a]+"\"";
_root["Web_"+this.a].setTextFormat(myformat1);
_root["Planta_"+this.a].text = myVar["planta"+this.a];
_root["Planta_"+this.a].setTextFormat(myformat);

if (myVar["planta"+this.a] == "1") {
myVar["planta"+this.a] = "▼ ";
}
if (myVar["planta"+this.a] == "2") {
myVar["planta"+this.a] = "▲ ";
}
if (myVar["planta"+this.a] == "3") {
myVar["planta"+this.a] = "▲▼ ";
}

if (_root["Link_"+this.a].text == "undefined"){
_root["Link_"+this.a].text = "";
}
if (_root["Web_"+this.a].text == "undefined"){
_root["Web_"+this.a].text = "";
}
if (myVar["planta"+this.a] == "undefined") {
myVar["planta"+this.a] = "";
}
if (_root["Link_"+this.a].htmlText == "undefined"){
_root["Link_"+this.a].htmlText = "";
}
// Lista_Nombre.text = myVar["tienda"+this.a];
_root["Link_"+this.a].html = true;
_root["Link_"+this.a].htmlText = myVar["planta"+this.a]+"<a href="+_root["Web_"+this.a].text+">"+myVar["tienda"+this.a]+"</a>";
_root["Link_"+this.a].setTextFormat(myformat);
// este es el codigo

//--------------------------------------------------------

//
if (_root["Link_"+this.a].text == "undefinedundefined"){
_root["Link_"+this.a].text = "";
}
if (_root["Link_"+this.a].htmlText == "undefined"){
_root["Link_"+this.a].htmlText = "";
}

alto = alto + 15;
nivel = nivel + 1;
lineas = lineas + 1;
} else {
lineas = 1;
x = x + 200;
x1 = x1 + 200;
nivel = nivel + 1;
alto = 347.0;

}
}
} else {
trace("Error loading page");
}
}


}






function borrarseccion() {
for(this.a=1;this.a<=26;this.a++){
_root["Link_"+this.a].text = "";
_root["Web_"+this.a].text = "";
}
}
stop();

Como ven? se podra hacer. ya que las pruebas que he hecho no me funcionan

Por marcelomty

14 de clabLevel



 

firefox
Citar            
MensajeEscrito el 12 Abr 2007 10:28 pm
Pon

Código :

 


Y sangralos para verlo mejor....

Por Suriv

131 de clabLevel



 

firefox
Citar            
MensajeEscrito el 13 Abr 2007 03:55 am
Hola, no se puede ver el codigo que escribis .. lo podrias volver a escribir ? porfas ..

Por marcelomty

14 de clabLevel



 

firefox
Citar            
MensajeEscrito el 13 Abr 2007 06:46 am
no escribi ningun codigo, solo te exponia que porfavor pusieras los tags [code]

Para que lo vieramos mejor..... Lo estoy mirando para ayudarte.....

Por Suriv

131 de clabLevel



 

firefox
Citar            
MensajeEscrito el 13 Abr 2007 08:40 pm
A ok, Bien la idea es crear botones con este script. Pero!!!!

Código :

function generar_boton(ruta:MovieClip, nombre:String, posx:Number, posy:Number, contenido:String)
{
   var clip:MovieClip = ruta.createEmptyMovieClip(nombre, ruta.getNextHighestDepth());
   clip._x = posx;
   clip._y = posy;
   clip.createTextField("texto", 1, 0, 0, 100, 20);
   clip.texto.text = contenido;
   clip.onRelease = function()
   {
      trace("hola, soy el botón ["+nombre+"] "+contenido);
   };
}

for (var i:Number = 1; i<=10; i++)
{
   var num:String = String(i);
   generar_boton(this, "bot"+num, 10, i*20, "botón "+num);
}
//--------------------------------------------------------


Necesito que los botones que se crean lleven de nombre en vez de "botón "+num ... lleven los nombres que estan en una base de datos mysql que bajo con este script.
que se extraen con .. ejem: extraerseccion("5"); <-- Las secciones van del 1 al 6.

Código :

function extraerseccion(seccion) {
myVar = new LoadVars();
   myVar.load('http://www.zonadesistema.com/404/lista.php?id='+seccion);
    myVar.onLoad = function( success ){
      if(success){
         alto = 350.0;
         nivel = 0;
         x = 13.0;
         x1 = 800.0;
         lineas = 1;
             if (myVar.total == "undefined"){
                myVar.total = "1";
                }
         
         for(this.a=1;this.a<=15;this.a++){
            if (lineas <=7) {
         createTextField(["Link_"+this.a], nivel,x,alto,300.2,35.3);
         
         nivel = nivel+1;
         trace (nivel);
         createTextField(["Web_"+this.a], nivel,x1,alto,30.2,17.3);
         
         trace(b);
         trace(["Web_"+this.a]);
          
         
         
         myformat = new TextFormat();
         //myformat.bullet = true;
         myformat.color = 0x000000;
         myformat.size = 11;
         myformat.font = "arial";
         myformat.html = true;
         myformat.bold = true;
         
         myformat1 = new TextFormat;
         myformat1.multiline = true;
         myformat1.color = 0xFF0000;
         myformat1.size = 11;
         myformat1.bold = true;
         myformat1.font = "arial";
       
            
         _root["Tienda_"+this.a].text = myVar["tienda"+this.a];
         _root["Tienda_"+this.a].setTextFormat(myformat1);
         _root["Web_"+this.a].text = "\""+myVar["web"+this.a]+"\"";
         _root["Web_"+this.a].setTextFormat(myformat1);
          _root["Planta_"+this.a].text = myVar["planta"+this.a];
         _root["Planta_"+this.a].setTextFormat(myformat);   
         
         if (myVar["planta"+this.a] == "1") {
            myVar["planta"+this.a] = "▼   ";
         }
         if (myVar["planta"+this.a] == "2") {
            myVar["planta"+this.a] = "▲   ";
         }
         if (myVar["planta"+this.a] == "3") {
            myVar["planta"+this.a] = "▲▼ ";
         }
                  
         if (_root["Link_"+this.a].text == "undefined"){
                _root["Link_"+this.a].text = "";
                }
         if (_root["Web_"+this.a].text == "undefined"){
                _root["Web_"+this.a].text = "";
                }
         if (myVar["planta"+this.a] == "undefined") {
            myVar["planta"+this.a] = "";
         }   
         if (_root["Link_"+this.a].htmlText == "undefined"){
                _root["Link_"+this.a].htmlText = "";
                }    
         // Lista_Nombre.text = myVar["tienda"+this.a];
         _root["Link_"+this.a].html = true;
         _root["Link_"+this.a].htmlText = myVar["planta"+this.a]+"<a href="+_root["Web_"+this.a].text+">"+myVar["tienda"+this.a]+"</a>";
         _root["Link_"+this.a].setTextFormat(myformat);
            // este es el codigo

//--------------------------------------------------------
 
               //
         if (_root["Link_"+this.a].text == "undefinedundefined"){
                _root["Link_"+this.a].text = "";
                }
         if (_root["Link_"+this.a].htmlText == "undefined"){
                _root["Link_"+this.a].htmlText = "";
                }    
      
         alto = alto + 15;
         nivel = nivel + 1;
         lineas = lineas + 1;
            } else {
            lineas = 1;
            x = x + 200;
            x1 = x1 + 200;
            nivel = nivel + 1;
            alto = 347.0;
            
            }
         }
        } else {
        trace("Error loading page");
          }
   }
                           
   
   }

   
             
            
   

function borrarseccion() {
             for(this.a=1;this.a<=26;this.a++){
         _root["Link_"+this.a].text = "";
          _root["Web_"+this.a].text = "";
   }
}
stop();


Entonces basicamente se trata de convinar los 2 scripts para crear los botones con los nombres dinamicos que bajo de la base de datos. como ven se podra ? .....

Por marcelomty

14 de clabLevel



 

firefox
Citar            
MensajeEscrito el 16 Abr 2007 03:00 pm

Código :

 <php? 

Por marcelomty

14 de clabLevel



 

firefox
Citar            
MensajeEscrito el 19 Abr 2007 04:29 am
niño

R-E-S-U-M-E tu problema

analiza todo desde el principio ¿que funciona y que no? cuado alles el problema solucionalo o posteas algo puntual

para crear botones yo te recomendaria ordenar todo en un xml

Por Inyaka

Claber

3176 de clabLevel

9 tutoriales
2 articulos

Genero:Masculino   Desarrollador de GAIA

Programador y fotógrafo

firefox

 

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