如何在AS3中循环播放不同的影片剪辑?

发布于 2024-08-11 03:24:43 字数 130 浏览 5 评论 0原文

我的图书馆里有五个电影剪辑。我想将每个加载到舞台并淡入和淡出。我以为我可以将它们调用到数组中,但我找不到如何引用它们。我的库里还有其他剪辑,所以我不能把它们全部拿下来。

有人知道该怎么做吗? AS3,请。

TIA

I have five movie clips in my library. I want to load each to the stage with a fade in and fade out. I thought I could just call them into an array, but I can't find how to reference them. I have other clips in the library too so I can't just grab them all.

Anyone know how to do this? AS3, please.

TIA

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

毁虫ゝ 2024-08-18 03:24:43

右键单击库中的 MovieClip 项目。选择“导出为 ActionScript”。然后这将填充类字段。选择“确定”两次。假设您的类名为“mcSquare”,

var mySquare:mcSquare = new mcSquare();
addChild(mySquare);

然后要淡入淡出,只需将 mySquare 的 alpha 设置为 0(直接在 addChild 之前或之后),然后将剪辑的 alpha 补间为 1。

编辑:

在库 mc0 中标记影片剪辑、mc1等。在此示例中,最高可达 mc6。

const MAX_ITEMS:uint = 7; //if you have seven movielips
var container:Array = new Array();

for (var i:int = 0;i < MAX_ITEMS;i++)
{
  var className:Class = getDefinitionByName("mc"+i) as Class;
  var newMovieClip:MovieClip= new className();
  container.push(newMovieClip)

}

for (var k:int = 0; k < MAX_ITEMS;k++)
{
   var myClip:MovieClip = container[k] as MovieClip;
   myClip.alpha = 0;
   stage.addChild(myClip);
   //apply tweening to myClip

}

Right click on your MovieClip item in the library. Select the "Export for ActionScript". This will then fill in the class field. Selected Ok twice. Lets say your class was called 'mcSquare'

var mySquare:mcSquare = new mcSquare();
addChild(mySquare);

To then fade them in simply set the alpha of the mySquare to 0 (directly before or after addChild) and then tween the alpha of the clip to 1.

EDIT:

Label the movieclips in your library mc0, mc1 and so on. In this example up to mc6.

const MAX_ITEMS:uint = 7; //if you have seven movielips
var container:Array = new Array();

for (var i:int = 0;i < MAX_ITEMS;i++)
{
  var className:Class = getDefinitionByName("mc"+i) as Class;
  var newMovieClip:MovieClip= new className();
  container.push(newMovieClip)

}

for (var k:int = 0; k < MAX_ITEMS;k++)
{
   var myClip:MovieClip = container[k] as MovieClip;
   myClip.alpha = 0;
   stage.addChild(myClip);
   //apply tweening to myClip

}
隔纱相望 2024-08-18 03:24:43

该效果通常称为图像旋转器。如果您的剪辑没有动态加载,为什么不将它们转储到时间线并手动设置它们淡入淡出的动画。这需要 5 分钟才能完成。

The effect is often called an image rotator. If your clips aren't being loaded dynamic, why not just dump them to the timeline and animate them fading by hand. That would take all of 5 minutes to accomplish.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文