ActionScript 时间轴控制
我正在动态加载一个文件,该文件将指示何时在某些帧上显示某些单词。但是,我在使用 ActionScript 的时间线控制概念时遇到了麻烦(我正在 Flash Builder 中以编程方式构建所有内容)。假设我的元组有框架和单词:
5, "duck"
13, "cow"
22, "pig"
每个元组都有一个关联的精灵。我想做的是如下的事情:
for (frame in timeline) { //should iterate from frame 0-22 (last frame in list)
if (frame in list) {
list[frame].alpha = 0;
}
}
我已经知道我的精灵显示是有效的,我只是对如何以这种方式播放时间线感到困惑,或者是否可以动态地执行此操作。
编辑:相关,我可以控制时间线的播放速度吗?
编辑:为了给出更彻底的解释,我希望可视化文本中单词随时间的出现情况。因此,“duck”可能显示为语料库中的第 5 个单词,“cow”可能显示为第 13 个单词,等等。我的列表包含单词位置(唯一)的元组以及出现在该位置的单词。我从语料库中选择了一小部分我感兴趣的单词,因此并未代表每个位置。我希望能够制作一部本质上从语料库开头开始的 SWF 电影,按照在语料库中出现的顺序浏览我的单词列表,然后显示该单词(并使其淡出)。因此,如果位置 5 和 10 处有一个单词,那么它的连续出现速度应该比位置 15 处有一个单词快得多,并且下一个单词直到 50 处才会出现。基本上,我想保留该时间分量。
I'm dynamically loading a file that will indicate when to show certain words at certain frames. However, I'm having trouble with the concept of timeline control from ActionScript (I'm building everything programmatically in Flash Builder). Let's say my tuples has frame and word:
5, "duck"
13, "cow"
22, "pig"
There is a sprite associated with each. What I would like to do is something like the following:
for (frame in timeline) { //should iterate from frame 0-22 (last frame in list)
if (frame in list) {
list[frame].alpha = 0;
}
}
I already know that my display of sprites works and whatnot, I'm just confused on how to play through the timeline in this kind of way, or if it's possible to dynamically do this.
EDIT: Related, can I control how fast the timeline plays?
EDIT: To give a more thorough explanation, I'm looking to visualize word appearances over time in a text. So "duck" may appear as the 5th word in a corpus, "cow" as the 13th word, etc. My list contains tuples of word positions (unique) and the word that appears at that position. I have a small selection of words that I'm interested in from the corpus, so not every position is represented. I would like to be able to have a SWF movies that essentially starts at the beginning of the corpus, go through my word list in order of appearance in the corpus, and then display the word (and have it fade out). So, if there's a word at position 5 and 10, then should appear in much more rapid succession than if there's a word at position 15, and the next one doesn't appear until 50. Basically, I would like to keep that temporal component.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在准确理解您要问的内容方面遇到了一些困难,但一般来说,为了控制时间线,请使用命令 play() stop() gotoAndPlay() gotoAndStop()
除此之外,我需要您更清楚地解释你到底想做什么。
添加:从您的编辑来看,听起来您只是想在用户单击按钮或其他内容时触发动画。因此,请在 Flash 中制作动画,然后使用我列出的命令来播放它。
ADDITION2:但是,如果您确实想在代码中执行此操作,那么这与时间线无关;使用补间库对淡入和淡出进行编程,例如 http://www.greensock.com/tweenlite/
I'm having a little trouble understanding exactly what you're asking about, but in general for controlling the timeline use the commands play() stop() gotoAndPlay() gotoAndStop()
Beyond that I'm gonna need you to explain more clearly what exactly you are trying to do.
ADDITION: From your edits it sounds like you simply want to trigger an animation when the user clicks a button or something. So make the animation in Flash and then use the commands I listed to play it.
ADDITION2: If however you definitely want to do this in code then that has nothing to do with the timeline; program the fading in and out using a tweening library like http://www.greensock.com/tweenlite/