添加嵌套影片剪辑并设置动态文本 AS3
我有一张美国地图,上面有许多城市(大约 12 个)的图标。当用户将鼠标悬停在这些图标之一上时,图标上方会弹出带有两个动态文本字段的动画剪辑。
每个城市的图标动画剪辑均以其所在州命名:state_(缩写)
即:state_TX
弹出的文本气球命名为:cityTag_mc
其中有两个动态文本字段:title_txt
& subTitle_txt
逻辑是当用户将鼠标悬停在 state_TX
上并输入该州的标题和副标题时添加 cityTag_mc
。
我的主要难题是如何将文本输入字段(并为气球设置动画)。我不太知道从哪里开始。我想在动作脚本中设置每个状态的文本。我从哪里开始?最佳实践是什么?
I have a map of the US with icons over a number of cities (about 12). When the user hovers their mouse over one of these icons a movieclip with two dynamic text fields pop-up over the icon.
Each city's icon movieclip is named after it's home state: state_(abbreviation)
ie: state_TX
The pop-up text balloon is named: cityTag_mc
Inside that is two dynamic text fields: title_txt
& subTitle_txt
The logic is to add the cityTag_mc
when the user hovers over state_TX
and input that state's title and sub title.
My main hang-up is how to feed text into the fields (and animate the balloon). I don't quite know where to start. I would like to just set the text for each state in the Action Script. Where do I start? What is the best practice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建所有城市图标并将它们放在舞台上并给它们指定实例名称后,然后将它们放入数组中。这只是为了让事情更容易管理。
cityIcons.push(state_tx), cityIcons.push(state_ca)
等现在我们需要添加代码来显示气球。你也提到了动画化。将在 cityTag_mc 中生长的气球动画放置在文本字段下方。为其指定一个实例名称,例如气球_mc。
现在我们需要添加监听器。我们将循环遍历数组,因此只需编写一次。
您可以将一个名为 cityTag_mc 的气球实例放置在舞台上并将“visible”设置为 false,也可以根据需要创建和删除。这只是一个指南,不要认为它是 100%,因为这只是我的想法。
Once you have created all the city icons and placed them on stage and given them instance names then put them in an array. This is just to make things easier to manage.
cityIcons.push(state_tx), cityIcons.push(state_ca)
etcNow we need to add the code to get the balloon to show. You mentioned animating it as well. Place your animation of a balloon growing in the cityTag_mc underneath your textfields. Give it an instance name for example balloon_mc.
Now we need to add the listeners. We will loop over our array so we only have to write it once.
You can place an instance of the balloon called cityTag_mc already on stage and set visible to false, or you can create and remove as needed. This is just a guide don't take it as 100% as this is just off the top of my head.