jeudi 28 mai 2015

AS3 - Add scroll bar to dynamically generated text field?

I'm new to actionscript 3, so please forgive me.

I am loading a text file into my flash file and then dynamically creating a text field which will take in the myBody text from that file. The problem is that the text in myBody could be very long, so I would like to add a scroll bar when needed to the dynamically generated text field. Is there any way to this?

var myTextLoader:URLLoader = new URLLoader();
myTextLoader.dataFormat=URLLoaderDataFormat.VARIABLES;

var myTextField_txt:TextField = new TextField();
myTextField_txt.multiline = true;
myTextField_txt.wordWrap = true;
myTextField_txt.border = true;
myTextField_txt.height = 100;

myTextLoader.addEventListener(Event.COMPLETE, onLoaded);

function onLoaded(e:Event):void {
     myTextField_txt.text = e.target.data.myBody;

     addChild(myTextField_txt);

}

myTextLoader.load(new URLRequest("mySampleFile.txt"));

Aucun commentaire:

Enregistrer un commentaire