AS3: Embedding characters

拜拜、爱过 提交于 2019-12-25 03:09:01

问题


I having some trouble with TextFields and caracter embedding. As I have understood, the way to embed character in Flash, is to have a TextField in a movieclip that is exported to actionscript via some classname. Then have the TextField embed the characters.

But when i try to use that TextField in my project, I cannot auto resize the field any longer!? Is there a better way to embed charactes? or am I missing some unknow attribute? (and yes i have tried TextField.autoSize = "left" (or "center" or "right")).

The TextField is configured like this in Flash CS4:
Properties: http://screencast.com/t/0VB6KnNO6G
Library implementation: http://screencast.com/t/w3yQLqit0veI

And I embed the MovieClip containing the TextField like this:

protected var tabname:MovieClip = new Text(); // The property on the object

Adding the text and setting its Settings:

var txt:TextField = tabname.txt;

        if( !contains(tabname) )
        {
            addChild(tabname);

            var format:TextFormat = new TextFormat();
                format.bold = true;
                format.font = "Arial";
                format.size = 12;
                format.align = "left";

            var dropShadow = new DropShadowFilter(0);
                dropShadow.color = 0xFFFFFF;
                dropShadow.strength = 2;
                dropShadow.blurX = dropShadow.blurY = 5;
                dropShadow.alpha = .7;

            txt.type = TextFieldType.DYNAMIC;
            txt.multiline = tabname.wordWrap = false;
            txt.autoSize = TextFieldAutoSize.LEFT;
            txt.defaultTextFormat = format;
            txt.filters = [dropShadow];
            txt.mouseEnabled = false;
            txt.x = 10;
        }

        txt.text = value;
        txt.y = Math.ceil((tabmask.height - txt.height) /2);

回答1:


To embed fonts, don't rely on wrapping them in MovieClips in the library. They should be embedded correctly as Fonts. I have included some basic steps below for embedding fonts, then an example for your particular situation:

1 - Make the textfield Dynamic and click the Embed.. button

2 - Name the font with something meaningful (like the fonts name) and tick the character sets you will be using (usually I select caps, lowercase, numbers and punctuation). Also note the Style is 'Bold', you will need to embed a font set for each style. So if you want to use Bold and Regular, you need to embed 2 fonts.

3 - If you plan on adding textfields dynamically through ActionScript, goto the ActionScript tab and add a class for it (again, use a meaningful name)

4 - Finally click ok, and away you go. I have setup an example, using these steps, and the auto size method, you can see the results below




回答2:


In Flash, you can click the [Embed...] button below the TextField's character properties. In the window that you get then, you can specify which characters you want embedded in your textfield.

There's a lot more to say about font embedding but this is the simple story. Flash CS5 added TLF TextFields but I don't think you were referring to those, right?

The autoSize property really has nothing to do with font embedding but I guess your TextField is not Dynamic when you cannot auto resize it?

Are you using CS5 or CS4 or earlier by the way?



来源:https://stackoverflow.com/questions/5626386/as3-embedding-characters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!