Question

I have a MovieClip that fades in and then fades out. I'd like to find the half way mark in this movie clip and pause it. However in EaselJS I cannot find any way to get the movie clip's current frame position. Is this possible?

I'd like to do something like the following:

 canvas = document.getElementById("introCanvas");
        exportRoot = new lib.MyMovieClip();
        exportRoot.onTick = function () {

            //get the mc's length in frames
            //get the current frame position
            //if current frame postion == mc's lenght / 2
                   //then pause movie clip


        };

Can anyone provide me with some suggestions or ideas for how I might accomplish the above?

Thanks!

Was it helpful?

Solution

After reading through the documentation, it seems that a TweenJS Timeline is automatically allocated to manage the change in the animation, it doesn't look like there are any actual frames like we see in flash.

If you look at the docs for TweenJS Timeline its possible you could use the duration property, as the docs state:

Read-only property specifying the total duration of this timeline in milliseconds (or ticks if useTicks is true). This value is usually automatically updated as you modify the timeline. See updateDuration for more information.

So if you get the duration and divide by 2, or multiply by 0.5 ;) then you could find out the middle point of your animation. Try using this in your onTick method to see if it works.

OTHER TIPS

I always do this...

(movieclip.timeline.position)%movieclip.timeline.duration

Or another way...

var tl = movieclip.timeline;
var d = timeline.duration;

(tl.position)%d

You have to get the movieclip's timeline's position & duration, and add a %. This will get the current frame of the movieclip.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top