AS3 Animated Bitmap Class:同时播放不同帧率的位图动画
这个工具类专门用来解决在同一个swf中播放不同帧率位图动画的问题,尤其是游戏有这方面的需求.
甚至可以指定多个的动画按不同帧率播放,比较实用.
源代码下载:http://files.hexagonstar.com/classes/as3/animatedbitmap.zip
(注:包括了一个名叫HDRS-CreateImageSequence的jsx脚本,这个脚本是用Photoshop CS将一系列的位图做成位图序列的.选中了多个位图,再执行这个脚本即可做成位图序列.不过要求这些位图都是长宽相同的.)
动画演示(这个动画是99帧/秒的,但里面的位图动画是24帧/秒)
http://files.hexagonstar.com/lab ... matedBitmapDemo.swf
原帖见:
AS3 Animated Bitmap Class
原文:
AS3 Animated Bitmap Class
The AnimatedBitmap class provides functionality for Bitmap objects that are animated by using a series of still images. When creating a new AnimatedBitmap you provide a BitmapData object that contains an image that consists of the ’single-frame’ images for the animation.
What are the advantages over using a generic MovieClip? When writing games you might have several animated graphics (also called sprites, but not related to the AS3 Sprite class) that should run with a different framerate than the game’s global framerate. Let’s say your game runs with a global framerate of 99 and you put several animated sprites into your game that were created for playing back with a framerate of 24. With a MovieClip all those sprites would also play with a framerate of 99 which means they play way too fast. However with an AnimatedBitmap you can set every framerate individually. There are a couple of other advantages like that a Bitmap is more lightweight than a MovieClip and it has a isPlaying() method. Also it changes the way of how to embed assets. Instead of embedding many files for one animation only one image for a whole animation sequence is embedded which has positive effects on the file size. The ring sequence used in the demo has 21 frames that use 102Kb as single images but only 44Kb when they are combined to one image.
The following demonstration plays with a global framerate of 99 but all AnimatedBitmap instances play at a framerate of 24 …
You can download the class including demo source code and demo image here.
Changes in v1.1
The timer object used to time the frame animation has now been made external. For this purpose a custom FrameRateTimer class has been added. This has the advantage that AnimatedBitmap objects don’t use their own timer objects anymore. Instead you can use one timer for many animated objects if they use the same framerate. This saves memory and CPU cycles. However you are still able to use one FrameRateTimer for every animated object if it is desired.
Also an IAnimatedDisplayObject interface has been added so that future animated display object types can be integrated more easily.
Also included is a jsx script for Photoshop CS named HDRS-CreateImageSequence that can be used to easily create a ’single-frames image’ with Photoshop. Simply run the script in Photoshop and choose the images in the file browser that appears. Photoshop will then generate a single image with all the frames laid out horizontally. All images should have the same size to get a correct animation sequence. Also sometimes you need to fine-tune the position of some frames, e.g. for the ring in the demo (which was rendered to single frame images from a 3D modeler) I had to justify the horizontal alignment a bit on some frames because otherwise the animation would glitch to left/right by some pixels.
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |