我要嵌入静态文本,基本上是一个帮助文件。类似于
const的帮助:字符串=这是一个帮助热线。
除了它会从一个文件中得到它?
const的帮助:字符串= //从一个静态文件中的文本
解决方案
下面是一个简单的例子:
公共类EmbedText扩展Sprite
{
[嵌入(来源=TextFile.txt的,MIMETYPE =应用程序/八位字节流)]
会将myText变种:类;
公共职能EmbedText()
{
VAR TXT:的ByteArray =会将myText新()作为ByteArray的;
跟踪(txt.toString());
}
}
这将包括文件TextFile.txt的'到您的SWF在编译时。如果要加载从服务器在运行时的文本文件,你应该使用URLLoader类。
I want to embed static text, basically for a help file. Something like
const help:String = "This is a help line.";
except for it would get it from a file?
const help:String = //retrieve text from a static file
解决方案
Here's a quick 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' into your SWF at compile-time. If you want to load the text-file from the server at run-time, you should instead use the URLLoader class.