Loading:


    TextFormat getTextExtent [AS 2]

    Klasa: TextFormat

    Kompatybilność: ActionScript 1.0, Flash 6+

     

    getTextExtent(tekst:String, [szerokosc:Number]) : Object

     

    Zwraca informację o wymiarach tekstu, dla ciągu znaków.

     

    Tekst jets traktowany jako czysty tekst (nie HTML).

     

    Ta metoda zwrca obiekt z 6 właściwościami: ascent, descent, width, height, textFieldHeight, oraz textFieldWidth. Wszystkie są mierzone w pikselach.

     

    Jeśli parametr szerokosc jest określony, wtedy zawijanie wyrazów jest nadawane na określony tekst. To pozwala Ci określić wysokość, na jakiej pudełko tekstu pokazuje cały określony tekst.

     




    Napisz Artyku³

    Listing

    //#1

    var moj_str:String = "Small string";


    var moj_fmt:TextFormat = new TextFormat();
    with (moj_fmt) {
        font = "Arial";
        bold = true;
    }


    var metrics:Object = moj_fmt.getTextExtent(moj_str);


    this.createTextField("moj_txt", this.getNextHighestDepth(), 100, 100, metrics.textFieldWidth,
    metrics.textFieldHeight);
    moj_txt.border = true;
    moj_txt.wordWrap = true;

    moj_txt object.
    moj_txt.text = moj_str;
    moj_txt.setTextFormat(moj_fmt);

    //#2


    var moj_fmt:TextFormat = new TextFormat();
    // Specify formatting properties for the TextFormat object:
    moj_fmt.font = "Arial";
    moj_fmt.bold = true;
    moj_fmt.leading = 4;

    var textToDisplay:String = "Adobe Flash Player 9 text metrics demonstration.";


    var metrics:Object = moj_fmt.getTextExtent(textToDisplay, 100);


    this.createTextField("moj_txt", this.getNextHighestDepth(), 50, 50-metrics.ascent, 100,
    metrics.textFieldHeight);
    moj_txt.wordWrap = true;
    moj_txt.border = true;
    // Assign the text and the TextFormat object to the TextObject:
    moj_txt.text = textToDisplay;
    moj_txt.setTextFormat(moj_fmt);




    Dodano przez: divix
    Ranga: Administrator serwisu Punktów: 0
    Komentarze użytkowników
      • Tre¶æ komentarza
        Kod do komentarza (opcjonalnie)
        PHP JavaScript MySQL Smarty SQL HTML CSS ActionScript
        Autor
        Token
        token

         

         








    funkcje.net
    Wszelkie prawa zastrzeżone©. | Funkcje.net 2008-2025 v.1.5 | design: diviXdesign & rainbowcolors