Visualizzazione dei risultati da 1 a 3 su 3

Discussione: Effetto su testo

  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2003
    Messaggi
    51

    Effetto su testo

    Ciao a tutti,
    sto cercando di capire come funziona questo effetto su testo con flash, scaricato da html.it da questa pagina http://flash-mx.html.it/movies/view_movie.asp?id=685 (text_fx_by_flyermx).
    La modifica che vorrei fare, è semplicemente la continuità dell’effetto, nel senso che una volta sfumato il testo in uscita, vorrei che ricominciasse da capo.
    Questo è l’action script:

    function charPositions(tFormat, str, depth) {
    _root.createTextField("temp", depth, 0, -300, 100, 400);
    temp.autosize = true;
    temp.embedFonts = true;
    temp.setNewTextFormat(tFormat);
    var arr = [];
    temp.text = str;
    var totalWidth = temp.textWidth;
    for (var i = 0; i<str.length; i++) {
    temp.text = str.substr(i);
    arr[i] = totalWidth-temp.textWidth;
    }
    return arr;
    }
    function setUpText(str, forma, lineLength) {
    var positions = charPositions(forma, str, 2000);
    var currentLine;
    var lineHeight = forma.getTextExtent(str).height;
    var finalPositions = [];
    for (var i = 0; i<positions.length; i++) {
    if (positions[i]>(lineLength+subtracta)) {
    subtracta = positions[i];
    currentLine++;
    }
    var x = positions[i]-subtracta;
    var y = lineHeight*currentLine;
    finalPositions[i] = {char:str.charAt(i), x:x, y:y};
    }
    return finalPositions;
    }
    function drawNext() {
    var noo = this.createEmptyMovieClip("lett"+this.count, this.count);
    var nextObj = charPos[this.count];
    noo._x = nextObj.x;
    noo._y = nextObj.y;
    noo.createTextField("tex", 1, 0, 0, 100, 100);
    noo.tex.text = nextObj.char;
    noo.tex.embedFonts = true;
    noo.tex.selectable = false;
    noo.tex.setTextFormat(mt);
    noo._alpha = 30;
    noo.onEnterFrame = function() {
    this._alpha += 5;
    if (this._alpha>=500) {
    this.onEnterFrame = function() {
    if (this._alpha>=0) {
    this._alpha -= 5;
    } else if (this._alpha<0) {
    delete this.onEnterFrame;
    }
    };
    }
    };
    this.count++;
    if (this.count>charPos.length) {
    delete this.onEnterFrame;
    }
    }
    function init(str, tForm, lineLength) {
    charPos = setUpText(str, tForm, lineLength);
    this.count = 0;
    this.onEnterFrame = drawNext;
    }
    mt = new TextFormat();
    mt.font = "Exotc350 DmBd BT";
    mt.size = 24;
    mt.color = 0xffffff;
    mt.bold = true;
    str = "Testo da sostituire testo da sostituire.";
    init(str, mt, 520);
    stop();


    Ho provato ad eliminare lo stop alla fine, ma non funziona più niente, e non funziona neanche sostituendolo con ‘go to…’.
    C’è qualcuno di voi che ha già usato questo effetto e mi sa aiutare?
    Grazie

  2. #2
    Utente bannato
    Registrato dal
    Mar 2002
    Messaggi
    1,322
    cambialo con questo




    function charPositions(tFormat, str, depth) {
    _root.createTextField("temp", depth, 0, -300, 100, 400);
    temp.autosize = true;
    temp.embedFonts = true;
    temp.setNewTextFormat(tFormat);
    var arr = [];
    temp.text = str;
    var totalWidth = temp.textWidth;
    for (var i = 0; i<str.length; i++) {
    temp.text = str.substr(i);
    arr[i] = totalWidth-temp.textWidth;
    }
    return arr;
    }
    function setUpText(str, forma, lineLength) {
    var positions = charPositions(forma, str, 2000);
    var currentLine;
    var lineHeight = forma.getTextExtent(str).height;
    var finalPositions = [];
    for (var i = 0; i<positions.length; i++) {
    if (positions[i]>(lineLength+subtracta)) {
    subtracta = positions[i];
    currentLine++;
    }
    var x = positions[i]-subtracta;
    var y = lineHeight*currentLine;
    finalPositions[i] = {char:str.charAt(i), x:x, y:y};
    }
    return finalPositions;
    }
    function drawNext() {
    var noo = this.createEmptyMovieClip("lett"+this.count, this.count);
    var nextObj = charPos[this.count];
    noo._x = nextObj.x;
    noo._y = nextObj.y;
    noo.createTextField("tex", 1, 0, 0, 100, 100);
    noo.tex.text = nextObj.char;
    noo.tex.embedFonts = true;
    noo.tex.selectable = false;
    noo.tex.setTextFormat(mt);
    noo._alpha = 30;
    noo.onEnterFrame = function() {
    this._alpha += 5;
    if (this._alpha>=500) {
    this.onEnterFrame = function() {
    lunghezza = length(str);
    if (_root["lett"+lunghezza]._alpha<0) {
    init(str, mt, 520);
    }
    if (this._alpha>=0) {
    this._alpha -= 5;
    } else if (this._alpha<0) {
    delete this.onEnterFrame;
    }
    };
    }
    };
    this.count++;
    if (this.count>charPos.length) {
    delete this.onEnterFrame;
    }
    }
    function init(str, tForm, lineLength) {
    charPos = setUpText(str, tForm, lineLength);
    this.count = 0;
    this.onEnterFrame = drawNext;
    }
    mt = new TextFormat();
    mt.font = "Arial";
    mt.size = 24;
    mt.color = 0xffffff;
    mt.bold = true;
    str = "ciao da emanuel";
    init(str, mt, 520);
    stop();

  3. #3
    Utente di HTML.it
    Registrato dal
    Jul 2003
    Messaggi
    51

    Grazie Emanuel!

    Ho fatto come mi hai detto, funziona.
    grazie ancora

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.