Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Caricare testo esterno in array

    Sto studiando questa funzione spettacolare per creare dinamicamente dei bottoni.
    Come potete vedere le scritte dei bottoni sono inserite in un array. E fin qui tutto bene.
    Il problema sorge quando cerco di popolare l'array dinamicamente attraverso un onLoad: non funziona più niente. Non riesco a capire se tutto codice deve metterlo all'interno dell'onLoad oppure fuori. Eppure le scritte esterne vengono inserite nell'array correttamente. dhò:


    function createButton(name, where, depth, x, y, width, height, text, color)
    {
    var mc = where.createEmptyMovieClip(prova, depth);
    mc._x = x;
    mc._y = y;
    mc.moveTo(0, 0);
    mc.lineStyle(1, 0x000000, 100);
    mc.beginFill(color, 100);
    mc.lineTo(width, 0);
    mc.lineTo(width, height);
    mc.lineTo(0, height);
    mc.lineTo(0, 0);
    mc.endFill();
    mc.createTextField("txt", 1, 0, 0, 1, 1);
    mc.txt.autoSize = "left";
    mc.txt.text = text;
    mc.txt._x = Math.round((width / 2) - (mc.txt._width / 2));
    mc.txt._y = Math.round((height/ 2) - (mc.txt._height/ 2));
    var myformat = new TextFormat("Verdana", 14, 0x55CCCC);
    mc.txt.setTextFormat(myformat);
    return mc;
    }
    function init(){
    var testi = ["primo pulsante", "secondo pulsante", "terzo pulsante"];
    var colori = [0xFFCC00, 0x00CC99, 0xFF00FF];
    for(var i = 0; i < testi.length; i++){
    var profondita = i;
    var nome = "pulsante" + i;
    var posizione = 140 * i;
    var but = createButton(nome, this, profondita, posizione, 50, 130, 25, testi[i], colori[i]);
    but.testo = testi[i];
    but.onRelease = function(){
    trace(this.testo)
    };
    }
    }
    init();

  2. #2
    Io ho fatto così:

    MA NON FUNZIONA!!! E' DA DUE ORE CHE STO FACENDO TENTATIVI. Dove sbaglio? grazie


    scambia=new LoadVars()
    scambia.tipo=tipologia;
    scambia.sendAndLoad("db_progetti.php",scambia);
    scambia.onLoad=function(){
    pulsanti=new Array();
    tot=this.totale;
    for(i=0;i<4;i++){
    pulsanti.push(this["ele"+i]);
    profondita = i;
    b=i+1;
    posizione = (80 * i)+50;
    but.createEmptyMovieClip("rea"+b, i);
    but["rea"+b]._x = posizione;
    but["rea"+b]._y = 4;
    with(but["rea"+b]){
    moveTo(0,0);
    lineStyle(1, 0xFFFFFF,100);
    beginFill(0xFFFFFF,100);
    lineTo(70, 0);
    lineTo(70,20);
    lineTo(0,20);
    lineTo(0, 0);
    endFill();
    }
    but["rea"+b].createTextField("txt", 1, 0, 0,70,20);
    but["rea"+b].txt.autoSize = "center";
    but["rea"+b].txt.text = pulsanti[i];
    but["rea"+b].txt._x = Math.round((width / 2) - (but["rea"+b].txt._width / 2));
    but["rea"+b].txt._y = Math.round((height/ 2) - (but["rea"+b].txt._height/ 2));
    var myformat = new TextFormat("Verdana", 13, 0x8B99A6);
    but["rea"+b].txt.setTextFormat(myformat);
    but.numero=b;
    but.testo =pulsanti[i];
    but.onRelease = function(){
    _root.finestra.pag.gallery.play();
    _root.finestra.pag.gallery.cart=this.testo;
    }
    but.onRollOver=function(){
    _global.sele=this.numero;
    }
    }

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.