开发者

How do you load a folder full of png files to construct an AS3 movie clip?

开发者 https://www.devze.com 2023-01-07 00:39 出处:网络
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 s

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...


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 ?


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.


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 ).

0

精彩评论

暂无评论...
验证码 换一张
取 消