如何在 actionscript 3 中嵌入静态文本? [英] How do I embed static text in actionscript 3?

查看:18
本文介绍了如何在 actionscript 3 中嵌入静态文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想嵌入静态文本,主要是为了帮助文件.类似的东西

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

推荐答案

这是一个简单的例子:

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());          
    }
}

这将在编译时将文件textfile.txt"包含到您的 SWF 中.如果要在运行时从服务器加载文本文件,则应改用 URLLoader 类.

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.

这篇关于如何在 actionscript 3 中嵌入静态文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆