How to insert static text in actionscript 3?

I want to insert static text, mainly for the help file. Sort of

const help:String = "This is a help line."; 

except that it will get it from the file?

 const help:String = //retrieve text from a static file 
+4
source share
1 answer

Here is an example:

 public class EmbedText extends Sprite { [Embed(source="textfile.txt",mimeType="application/octet-stream")] var myText:Class; public function EmbedText () { var txt:ByteArray = new myText() as ByteArray; trace(txt.toString()); } } 

This will include the file 'textfile.txt' in your SWF at compile time. If you want to download a text file from the server at runtime, you must use the URLLoader class.

+10
source

Source: https://habr.com/ru/post/1301761/


All Articles