Actionscript:如何旋转文本字段?
如何在 ActionScript 3.0 中旋转文本字段? 一旦我更改文本字段的旋转属性,它就不会显示。
例如:
var txtFld:TextField = new TextField();
txtFld.x = 100;
txtFld.y = 100;
txtFld.width = 300;
txtFld.height = 300;
txtFld.text = "Test String";
txtFld.rotation = 90;
addChild(txtFld);
How do you rotate a text field in actionscript 3.0? As soon as I change the rotation property of the text field, it does not display.
for example:
var txtFld:TextField = new TextField();
txtFld.x = 100;
txtFld.y = 100;
txtFld.width = 300;
txtFld.height = 300;
txtFld.text = "Test String";
txtFld.rotation = 90;
addChild(txtFld);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
为了查看旋转的文本,您必须嵌入字体。
In order to see rotated text, you'll have to embed the font.
另一种方法是,使用 BitmapData::draw 将文本字段复制到 BitmapData,然后创建包含结果的位图,并添加该结果到显示列表,而不是原始的
TextField
...这有一个很大的优点,即您不需要嵌入字体,这会减少 swf 文件大小...OTOH,您将失去所有TextField` 的交互性,并且 swf 在播放时需要更多 RAM,但后者并不太重要......
为了使文本看起来平滑,请将
Bitmap::smoothing
设置为true
...此外,如果您以更高分辨率渲染图像,它也会有所帮助...伪抗锯齿,可以这么说...绘制文本时,传递一个Matrix< /code> 放大 2 倍并缩小
Bitmap
2 倍...这样看起来会更好...greetz
back2dos
an alternative is, to copy the textfield into a
BitmapData
usingBitmapData::draw
and then creating aBitmap
containing the result, and adding that one to the display list, instead of the originalTextField
...this has the great advantage, that you don't need to embed the font, which reduces swf filesize ... OTOH, you will lose all of the TextField`'s interactivity, and the swf will need more RAM when playing, but the latter is not too significant ...
for the text to look smooth, set
Bitmap::smoothing
totrue
... also, it helps, if you render your image at a higher resolution ... pseudo-anti-aliasing, so to speak ... when drawing the text, pass aMatrix
scaled up by factor 2 and scale down theBitmap
by factor 2 ... that way it'll look better ...greetz
back2dos
支持 Christophe Herreman 的更多信息:ActionScript - 旋转文本
Some more info supporting Christophe Herreman : ActionScript - Rotating Text
我只是想将我的经验添加到这个问题中。 我也想旋转文本。
起初,我仅使用 ActionScript 嵌入字体。
但每次我设置 embedFonts = true 时,文本都会消失。 最后我屈服了,使用 Flash 嵌入字体。
终于成功了。
哦,我多么讨厌使用 Flash IDE 来做任何事情。 如果有人能够在不使用 Flash 的情况下做到这一点,请分享!
I just wanted to add my experience to this question. I too wanted to rotate text.
At first, I embedded the font using only ActionScript.
But every time I set
embedFonts = true
, the text would disappear. Finally I gave in and embedded the font using Flash.It finally worked.
Oh how I loathe using the Flash IDE for anything. If anyone was able to do this without using Flash, please do share!
这对我有用。
在 CS5 中,我需要更改“字体嵌入”对话框中的设置才能使其正常工作。
要显示“字体嵌入”对话框,请单击“字符”面板中的“嵌入”按钮,或双击库中的字体符号。
然后,选择您希望能够旋转的字体并单击“Actionscript”选项卡。
最后,选中导出为 Actionscript 复选框。 保留默认值并单击“确定”。
下面是我使用的代码:
如果然后通过 AS 将旋转应用于该字段,我仍然可以看到字体。
This is what worked for me.
In CS5, I needed to change a setting in the Font Embedding dialog box for it to work.
To show the Font Embedding dialog, either click the Embed button in the Character panel, or double-click a Font symbol in the Library.
Then, select the font you want to be able to rotate and click the Actionscript tab.
Finally, check the Export for Actionscript checkbox. Leave the defaults and click OK.
Below is the code that I used:
If then then apply rotation to that field via AS, I still see the font.