@@ -322,6 +322,16 @@ this.createjs = this.createjs||{};
322322 this . _updateTimeline ( ) ;
323323 return this . timeline . getCurrentLabel ( ) ;
324324 } ;
325+
326+ /**
327+ * Use the {{#crossLink "MovieClip/duration:property"}}{{/crossLink}} property instead.
328+ * @method getDuration
329+ * @return {Number }
330+ * @protected
331+ **/
332+ p . getDuration = function ( ) {
333+ return this . timeline . duration ;
334+ } ;
325335
326336 /**
327337 * Returns an array of objects with label and position (aka frame) properties, sorted by position.
@@ -330,18 +340,35 @@ this.createjs = this.createjs||{};
330340 * @type {Array }
331341 * @readonly
332342 **/
333-
343+
334344 /**
335345 * Returns the name of the label on or immediately before the current frame. See TweenJS: Timeline.getCurrentLabel()
336346 * for more information.
337347 * @property currentLabel
338348 * @type {String }
339349 * @readonly
340350 **/
351+
352+ /**
353+ * Returns the duration of this MovieClip in seconds or ticks. Identical to {{#crossLink "MovieClip/duration:property"}}{{/crossLink}}
354+ * and provided for Flash API compatibility.
355+ * @property totalFrames
356+ * @type {Number }
357+ * @readonly
358+ **/
359+
360+ /**
361+ * Returns the duration of this MovieClip in seconds or ticks.
362+ * @property duration
363+ * @type {Number }
364+ * @readonly
365+ **/
341366 try {
342367 Object . defineProperties ( p , {
343368 labels : { get : p . getLabels } ,
344- currentLabel : { get : p . getCurrentLabel }
369+ currentLabel : { get : p . getCurrentLabel } ,
370+ totalFrames : { get : p . getDuration } ,
371+ duration : { get : p . getDuration }
345372 } ) ;
346373 } catch ( e ) { }
347374
@@ -511,13 +538,15 @@ this.createjs = this.createjs||{};
511538 var tl = this . timeline ;
512539 var synched = this . mode != MovieClip . INDEPENDENT ;
513540 tl . loop = ( this . loop == null ) ? true : this . loop ;
514-
541+
542+ var pos = synched ? this . startPosition + ( this . mode == MovieClip . SINGLE_FRAME ?0 :this . _synchOffset ) : ( this . _prevPos < 0 ? 0 : this . _prevPosition ) ;
543+ var mode = synched || ! this . actionsEnabled ? createjs . Tween . NONE : null ;
544+
545+ // pre-assign currentFrame so it is available to frame scripts:
546+ this . currentFrame = tl . _calcPosition ( pos ) ;
547+
515548 // update timeline position, ignoring actions if this is a graphic.
516- if ( synched ) {
517- tl . setPosition ( this . startPosition + ( this . mode == MovieClip . SINGLE_FRAME ?0 :this . _synchOffset ) , createjs . Tween . NONE ) ;
518- } else {
519- tl . setPosition ( this . _prevPos < 0 ? 0 : this . _prevPosition , this . actionsEnabled ? null : createjs . Tween . NONE ) ;
520- }
549+ tl . setPosition ( pos , mode ) ;
521550
522551 this . _prevPosition = tl . _prevPosition ;
523552 if ( this . _prevPos == tl . _prevPos ) { return ; }
0 commit comments