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
