AS3:如何将文本字段转换为MovieClips组?
我已经遇到过这个问题几次了:
我有一个动态创建的文本字段,我想将此文本字段转换为一个影片剪辑,其中包含文本的每个字母的子影片剪辑,以便我可以单独为字母设置动画(例如对待它们)作为粒子并使它们爆炸)。当然,转换后的影片剪辑看起来仍应与原始文本字段相同。
最快/最简单的方法是什么?
I encountered that problem already a few times:
I have a dynamically created textfield, and I would like to convert this textfield into a movieclip containing a childmovieclip for each letter of the text, so that i can animate the letters individually (for example treat them as particles and make them explode). Of course the converted movieclip should still look the same way as the original textfield.
What's the quickest/easiest way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以自己完成,但意味着大量编码(基本上,您应该创建包含字母的单个影片剪辑(作为文本字段或位图),而不是填充文本字段,将它们存储在数组中,并在需要时稍后播放它们)。
或者
只需使用 TweenMax 和 SplitTextField :)
You could do it by yourself, but implies lot of coding (basically, instead of filling the textfield, you should create singles movieclips containing a letter, either as textfield or bitmap, storing them in an array, and playing them later when needed).
OR
Simply use TweenMax and SplitTextField :)
只创建字符串中每个字符的影片剪辑会更容易
要获取字符串中每个字符的数组,请使用
split
var myString:String="StackOverflow";
var myArray:Array=myString.split(""); //['S', 't', 'a', 'c', 'k', 'O', 'v', 'e', 'r', 'f', 'l', 'o' , 'w'];
然后我想你知道方法
或
如果你有一个静态文本字段(其值不会改变),
你可以将它分开(右键单击>打破分开),这将为你提供包含以下内容的文本字段:个别字符
It would be easier to just create movieclips of each character in the string
To get an array of each character in the string, use
split
var myString:String="StackOverflow";
var myArray:Array=myString.split(""); //['S', 't', 'a', 'c', 'k', 'O', 'v', 'e', 'r', 'f', 'l', 'o', 'w'];
And then I suppose you know the way
OR
If you have a static textfield (whose value doesn't change)
You could break it apart (Right Click>Break Apart), and that will give you textfields containing individual characters
您可以使用名为“TextAnim”的开源库。
查看:- http://code.google.com/p/textanim/
You can use the opensource lib called "TextAnim".
Check out:- http://code.google.com/p/textanim/