论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > Flash AS编程教程
Tag:2.0,3.0菜鸟,游戏,,cs,技巧,源码,,文本,文字,函数,音乐,随机,拖拽,asp,access,xml,mc,视频教程

同时播放不同帧率的位图动画

文章类别:Flash AS编程 | 发表日期:2008-10-6 18:36:37


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.

上一篇:{教程}As3 缓动工具TweenLite 人气:2545
下一篇:{教程}Flash As3 : 定时运行 人气:3590
视频教程列表
文章教程搜索
 
Flash AS推荐教程
Flash AS热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058