mobile-graphic-easel-src-easeljs-display-BitmapAnimation.js / js
Displays frames or sequences of frames (ie. animations) from a sprite sheet image. A sprite sheet is a series of images (usually animation frames) combined into a single image. For example, an animation consisting of 8 100x100 images could be combined into a 400x200 sprite sheet (4 frames across by 2 high). You can display individual frames, play frames as an animation, and even sequence animations together. See the {{#crossLink "SpriteSheet"}}{{/crossLink}} class for more information on setting up frames and animations. <h4>Example</h4> var instance = new createjs.BitmapAnimation(spriteSheet); instance.gotoAndStop("frameName"); Currently, you <strong>must</strong> call either {{#crossLink "BitmapAnimation/gotoAndStop"}}{{/crossLink}} or {{#crossLink "BitmapAnimation/gotoAndPlay"}}{{/crossLink}}, or nothing will display on stage. @class BitmapAnimation @extends DisplayObject @uses EventDispatcher @constructor
parameter: {SpriteSheet} spriteSheet The SpriteSheet instance to play back. This includes the source image(s), frame dimensions, and frame data. See {{#crossLink "SpriteSheet"}}{{/crossLink}} for more information.
Dispatched when an animation reaches its ends. @event animationend
parameter: {Object} target The object that dispatched the event.
parameter: {String} type The event type.
parameter: {String} name The name of the animation that just ended.
parameter: {String} next The name of the next animation that will be played, or null. This will be the same as name if the animation is looping. @since 0.6.0
Specifies a function to call whenever any animation reaches its end. It will be called with three params: the first will be a reference to this instance, the second will be the name of the animation that just ended, and the third will be the name of the next animation that will be played. @property onAnimationEnd @type {Function} @deprecated In favour of the "animationend" event. Will be removed in a future version.
The frame that will be drawn when draw is called. Note that with some SpriteSheet data, this will advance non-sequentially. READ-ONLY. @property currentFrame @type {Number} @default -1
Returns the currently playing animation. READ-ONLY. @property currentAnimation @type {String} @final
Prevents the animation from advancing each tick automatically. For example, you could create a sprite sheet of icons, set paused to true, and display the appropriate icon by setting <code>currentFrame</code>. @property paused @type {Boolean} @default false
The SpriteSheet instance to play back. This includes the source image, frame dimensions, and frame data. See {{#crossLink "SpriteSheet"}}{{/crossLink}} for more information. @property spriteSheet @type {SpriteSheet}
Whether or not the image should be draw to the canvas at whole pixel coordinates. @property snapToPixel @type {Boolean} @default true
When used in conjunction with animations having an frequency greater than 1, this lets you offset which tick the playhead will advance on. For example, you could create two BitmapAnimations, both playing an animation with a frequency of 2, but one having offset set to 1. Both instances would advance every second tick, but they would advance on alternating ticks (effectively, one instance would advance on odd ticks, the other on even ticks). @property offset @type {Number} @default 0
Specifies the current frame index within the current playing animation. When playing normally, this will increase successively from 0 to n-1, where n is the number of frames in the current animation. @property currentAnimationFrame @type {Number} @default 0
@property _advanceCount @protected @type {Number} @default 0
@property _animation @protected @type {Object} @default null
@property DisplayObject_initialize @type {Function} @private
Initialization method. @method initialize @protected
Returns true or false indicating whether the display object would be visible if drawn to a canvas. This does not account for whether it would be visible within the boundaries of the stage. NOTE: This method is mainly for internal use, though it may be useful for advanced uses. @method isVisible
returns: {Boolean} Boolean indicating whether the display object would be visible if drawn to a canvas
@property DisplayObject_draw @type {Function} @private
Draws the display object into the specified context ignoring it's visible, alpha, shadow, and transform. Returns true if the draw was handled (useful for overriding functionality). NOTE: This method is mainly for internal use, though it may be useful for advanced uses. @method draw
parameter: {CanvasRenderingContext2D} ctx The canvas 2D context object to draw into.
parameter: {Boolean} ignoreCache Indicates whether the draw operation should ignore any current cache. For example, used for drawing the cache (to prevent it from simply drawing an existing cache back into itself).
Because the content of a Bitmap is already in a simple format, cache is unnecessary for Bitmap instances. You should not cache Bitmap instances as it can degrade performance. @method cache
Because the content of a Bitmap is already in a simple format, cache is unnecessary for Bitmap instances. You should not cache Bitmap instances as it can degrade performance. @method updateCache
Because the content of a Bitmap is already in a simple format, cache is unnecessary for Bitmap instances. You should not cache Bitmap instances as it can degrade performance. @method uncache
Begin playing a paused animation. The BitmapAnimation will be paused if either {{#crossLink "BitmapAnimation/stop"}}{{/crossLink}} or {{#crossLink "BitmapAnimation/gotoAndStop"}}{{/crossLink}} is called. Single frame animations will remain unchanged. @method play
Stop playing a running animation. The BitmapAnimation will be playing if {{#crossLink "BitmapAnimation/gotoAndPlay"}}{{/crossLink}} is called. Note that calling {{#crossLink "BitmapAnimation/gotoAndPlay"}}{{/crossLink}} or {{#crossLink "BitmapAnimation/play"}}{{/crossLink}} will resume playback. @method stop
Sets paused to false and plays the specified animation name, named frame, or frame number. @method gotoAndPlay
parameter: {String|Number} frameOrAnimation The frame number or animation name that the playhead should move to and begin playing.
Sets paused to true and seeks to the specified animation name, named frame, or frame number. @method gotoAndStop
parameter: {String|Number} frameOrAnimation The frame number or animation name that the playhead should move to and stop.
Advances the playhead. This occurs automatically each tick by default. @method advance
Returns a {{#crossLink "Rectangle"}}{{/crossLink}} instance defining the bounds of the current frame relative to the origin. For example, a 90 x 70 frame with <code>regX=50</code> and <code>regY=40</code> would return a rectangle with [x=-50, y=-40, width=90, height=70]. Also see the SpriteSheet {{#crossLink "SpriteSheet/getFrameBounds"}}{{/crossLink}} method. @method getBounds
returns: {Rectangle} A Rectangle instance. Returns null if the frame does not exist, or the image is not fully loaded.
Returns a clone of the BitmapAnimation instance. Note that the same SpriteSheet is shared between cloned instances. @method clone
returns: {BitmapAnimation} a clone of the BitmapAnimation instance.
Returns a string representation of this object. @method toString
returns: {String} a string representation of the instance.
@property DisplayObject__tick @type {Function} @private
Advances the <code>currentFrame</code> if paused is not true. This is called automatically when the {{#crossLink "Stage"}}{{/crossLink}} ticks. @protected @method _tick
Normalizes the current frame, advancing animations and dispatching callbacks as appropriate. @protected @method _normalizeCurrentFrame
Dispatches the "animationend" event. Returns true if a handler changed the animation (ex. calling {{#crossLink "BitmapAnimation/stop"}}{{/crossLink}}, {{#crossLink "BitmapAnimation/gotoAndPlay"}}{{/crossLink}}, etc.) @property _dispatchAnimationEnd @private @type {Function}
@property DisplayObject_cloneProps @private @type {Function}
@method cloneProps
parameter: {Text} o @protected
Moves the playhead to the specified frame number or animation. @method _goto
parameter: {String|Number} frameOrAnimation The frame number or animation that the playhead should move to. @protected
(C) Æliens 04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.