A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Trouble embeding fonts in dynamic text fields in as2

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    1

    Unhappy Trouble embeding fonts in dynamic text fields in as2

    I`m making a matching game that uses dynamic text fields, but cant embed the fonts, I`ve tried everything I could think of, even adding a text box with the embed fonts, or loading them from an external file, nothings absolutely happens, I`m completely clueless, can you help me?

    This is my code, is in as2, can`t change it to as3 cause the whole game stop s working,


    function aleatorio(min, max)
    {
    var _loc2 = true;
    if (usados.length <= max - min)
    {
    while (_loc2 != false)
    {
    var _loc1 = Math.floor(Math.random() * (max - min + 1));
    _loc2 = repetido(_loc1);
    } // end while
    usados.push(_loc1);
    return (_loc1);
    }
    else
    {
    return (0);
    } // end else if
    } // End of the function
    function repetido(num)
    {
    var _loc1 = false;
    for (i = 0; i < usados.length; i++)
    {
    if (num == usados[i])
    {
    _loc1 = true;
    } // end if
    } // end of for
    return (_loc1);
    } // End of the function
    stop ();
    var usados = new Array();
    _root.palabras_colocadas = 0;
    palabras_correctas = 0;
    listado_x = 700;
    listado_y = 400;
    origenx = 0;
    origeny = 0;
    estaba_en = -1;
    apagar = false;
    _root.frase = 2;
    var palabras = new Array("huts", "made", "mud", "straw");
    var correctas = new Array(false, false, false, false);
    var ocupadas = new Array(-1, -1, -1, -1);
    var my_font = new TextFormat();
    my_font.font = "ITC Serif Gothic Std Bold";
    my_font.color = 0;
    my_font.size = 30;
    palabras.embedFonts = true;
    my_font.bold = true;
    var i = 0;
    while (i < 4)
    {
    this["cuadro" + i].gotoAndStop(1);
    this.createEmptyMovieClip("myClip" + i, this.getNextHighestDepth());
    largo = palabras[i].length * 22;
    this["myClip" + i].createTextField("label", 1, 0, 0, largo, 40);
    this["myClip" + i].label.text = palabras[i];
    this["myClip" + i].label.setTextFormat(my_font);
    this["myClip" + i].onPress = function ()
    {
    temp = this._name;
    temp = Number(temp.charAt(6));
    if (ocupadas[0] == temp)
    {
    apagar = true;
    estaba_en = 0;
    } // end if
    if (ocupadas[1] == temp)
    {
    apagar = true;
    estaba_en = 1;
    } // end if
    if (ocupadas[2] == temp)
    {
    apagar = true;
    estaba_en = 2;
    } // end if
    if (ocupadas[3] == temp)
    {
    apagar = true;
    estaba_en = 3;
    } // end if
    if (!apagar)
    {
    estaba_en = -1;
    } // end if
    origenx = this._x;
    origeny = this._y;
    trace ("estaba en " + estaba_en);
    this.startDrag();
    };
    this["myClip" + i].onRelease = this["myClip" + i].onReleaseOutside = function ()
    {
    this.stopDrag();
    cual = this._name;
    cual = Number(cual.charAt(6));
    drop = eval(this._droptarget);
    trace (drop);
    donde = String(drop);
    cuadro = donde.substr(8, 6);
    donde = Number(donde.charAt(14));
    trace (cual + " en " + donde + " " + cuadro);
    if (cuadro == "cuadro")
    {
    if (ocupadas[donde] >= 0 && ocupadas[donde] <= 3 || donde == estaba_en)
    {
    apagar = false;
    this._x = origenx;
    this._y = origeny;
    }
    else
    {
    if (!apagar)
    {
    ++_root.palabras_colocadas;
    } // end if
    tramo = eval("tramo" + (donde + 1) + "_mc");
    tramo.gotoAndPlay(2);
    if (_root.palabras_colocadas >= 4)
    {
    startbtn.start();
    start_mc.gotoAndPlay(2);
    }
    else
    {
    palabra_ok.start();
    } // end else if
    largo = palabras[cual].length * 8.500000E+000;
    drop.gotoAndStop(2);
    this._y = drop._y - 22;
    this._x = drop._x - largo;
    ocupadas[donde] = cual;
    if (apagar)
    {
    apaga = eval("cuadro" + estaba_en);
    apaga.gotoAndStop(1);
    tramo = eval("tramo" + (estaba_en + 1) + "_mc");
    tramo.gotoAndPlay(6);
    ocupadas[estaba_en] = -1;
    correctas[estaba_en] = false;
    apagar = false;
    trace ("hay " + _root.palabras_colocadas + " palabras");
    if (_root.palabras_colocadas == 3)
    {
    trace ("apaga sin ruido");
    start_mc.gotoAndStop(1);
    } // end if
    } // end if
    trace (ocupadas[0] + " " + ocupadas[1] + " " + ocupadas[2] + " " + ocupadas[3]);
    if (cual == donde)
    {
    ++palabras_correctas;
    correctas[donde] = true;
    } // end if
    } // end if
    } // end else if
    if (cuadro == "myClip" || cuadro == "start_")
    {
    palabra_error.start();
    this._x = origenx;
    this._y = origeny;
    } // end if
    if (cuadro == "fondo")
    {
    if (apagar)
    {
    apaga = eval("cuadro" + estaba_en);
    apaga.gotoAndStop(1);
    tramo = eval("tramo" + (estaba_en + 1) + "_mc");
    tramo.gotoAndPlay(6);
    ocupadas[estaba_en] = -1;
    correctas[estaba_en] = false;
    --_root.palabras_colocadas;
    apagar = false;
    trace ("hay " + _root.palabras_colocadas + " palabras");
    if (_root.palabras_colocadas == 3)
    {
    startbtn.start();
    start_mc.gotoAndStop(1);
    } // end if
    } // end if
    } // end if
    };
    ++i;
    } // end while
    var ii = 0;
    while (ii < 4)
    {
    var numeroNuevo = aleatorio(1, 4);
    trace (numeroNuevo);
    this["myClip" + numeroNuevo]._x = listado_x;
    this["myClip" + numeroNuevo]._y = listado_y + 40 * i;
    ++ii;
    } // end while

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center