0

にテキストを配置するとうまく機能するスクリプトがありますが、Dynamic Textこれを外部.txtファイルからロードすると、ロードしたテキストは動的テキストに挿入されません。

これが私のコードです:

私の外部txtファイルでは、これを使用します:

_txt=Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

これを使用して、外部テキストを読み込みます。

loadText = new LoadVars();
loadText.load("letreiro.txt");
loadText.onLoad = function() {
    _root.textoletreiro = this._txt;
    trace(_root.textoletreiro); // the Output shows the text!
    mcText._txt.text = _root.textoletreiro; // here i'm puting the text on the Dynamic Text, but is not working.
};

そして、ここに私の水平スクロールコード:

var resetPos:Number = (mcText._txt._x * -1) + 2; 
var endOfText= mcText._txt._x - (mcText._txt.textWidth + 5); 


function scroller()
{   


    mcText._txt._width = mcText._txt.textWidth;
    mcText._txt.multiline = false;
    mcText._txt.autoSize = "right";

    mcText.onEnterFrame = function() {
        mcText._txt._x -= 1;  
        if (mcText._txt._x < endOfText)
        {
            mcText._txt._x = resetPos;
            delete this["onEnterFrame"]; 
            scroller();
        }
    }
}
scroller();  

私は何を間違っていますか?

PS:私のソースで編集letreiro.txt

4

1 に答える 1

0

ステージ上に mcText と呼ばれる MovieClip が 0,0 に配置され、その中に _txt と呼ばれる TextField があると仮定すると、次のコードはテキストをコンテナの端に達するまでスクロールし、その後 0 にリセットして再度スクロールします。

var text:String = "here is some text I would like to scroll.";
var fmt:TextFormat = new TextFormat("Arial", 32);

mcText._txt.multiline = false;
mcText._txt.wordWrap = false;
mcText._txt.autoSize = true;
mcText._txt.text = text;
mcText._txt.setTextFormat(fmt);

function scroller()
{   

    mcText.onEnterFrame = function() {
        mcText._txt._x -= 2; 

        if (Math.abs(mcText._txt._x) >= mcText._txt._width)
        {
            mcText._txt._x = 0;
            delete this["onEnterFrame"]; 
            scroller();
        }
    }
}
scroller(); 
于 2012-06-05T16:41:26.820 に答える