如何加载一个充满 png 文件的文件夹来构建 AS3 影片剪辑?
我看到很多 AS3 示例将 1 个图像文件加载到 1 帧影片剪辑中,但是如何获取一个装满图像的文件夹,加载它们并将每个图像视为单个影片剪辑的单独帧?
我似乎一直遇到的基本问题是如何在运行时创建关键帧......
I see plenty of AS3 examples of loading 1 image file into a 1 frame movieclip, but how can you take a folder full of images, load them and treat each image as an individual frame of a single movieclip?
The essential problem I seem to keep running into is how to create a keyframe during runtime...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我还没有真正尝试过,但也许如果你做类似
mc.addChild(image); 的 事情
mc.nextFrame();
mc.addChild(image2);
mc.nextFrame();
但无法肯定地告诉您它是否有效:)
您要使用此影片剪辑做什么?
I haven really tried it but maybe if you do something like
mc.addChild(image);
mc.nextFrame();
mc.addChild(image2);
mc.nextFrame();
Cant tell you for sure that it works though :)
What are you going to use this movieclip for ?
你不能做这样的事情,因为你不能在运行时创建关键帧,并且当使用代码将子项添加到MovieClip时,它不会将其添加到当前帧,它只会将其添加到剪辑的显示列表中,所以您动态添加的内容将出现在每一帧上。
您可能应该尝试加载图像并将它们存储在数组中,或者制作每个图像上都有的影片剪辑或精灵数组。这样,您就可以将所有图像包含在剪辑列表中,并且您仍然可以使用这些剪辑并在 Flash 影片中按照您想要的方式显示它们。
You can't do anything like that, because you can't create keyframes at runtime and when add a child to the MovieClip with code, it wont add it to the current frame, it will just add it to the clip's display list, so what you added dynamically will be on every frame.
You should probably try loading your images and storing them in an array or making an array of movie clips or sprites that each have on image. That way you have all the images in a list of clips, and you can still use those clips and display them however you want in your flash movie.
无法动态添加帧。
你可以做的是 __dominic 建议的:
通过将图像数据存储在数组中(或类似技术)来管理不同的帧,创建一个模仿影片剪辑的类
。另一种方法是使用精灵表。您可以在 wikipedia 和 this SO post
还有一些在线可用的实现(即 参见 spritesheet 类)。
There is no way to add frames dynamically.
What you can do is what __dominic suggests:
create a class that mimics a movieclip by managing different frames by storing image data in an array ( or similar technique)
A different approach would be to use a sprite sheet. You can find information about sprite sheets in wikipedia and in this SO post
There are also some implementations available online ( i.e. see spritesheet class ).