开发者

How do I embed static text in actionscript 3?

开发者 https://www.devze.com 2022-12-20 11:18 出处:网络
I want to embed static text, basically for a help file.Something like const help:String = \"This is a help line.\";

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号