flash - Horizontal dynamic text scrolling with external text -
i have script works nice if put text on dynamic text, if load external .txt file, text have loaded not inserted on dynamic text.
here code:
on external txt file use this:
_txt=pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. i use load external text.
loadtext = new loadvars(); loadtext.load("letreiro.txt"); loadtext.onload = function() { _root.textoletreiro = this._txt; trace(_root.textoletreiro); // output shows text! mctext._txt.text = _root.textoletreiro; // here i'm puting text on dynamic text, not working. }; and here horizontal scrolling code:
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(); what i'm doing wrong?
ps: edited source of letreiro.txt
assuming have movieclip on stage called mctext positioned 0,0 , inside textfield called _txt, following code scrolls text until hits edge of container resets 0 , scrolls again:
var text:string = "here text 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();
Comments
Post a Comment