Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I use milliseconds in tween when I add MovieClip to stage? #39

Closed
paveliko opened this issue Feb 2, 2014 · 2 comments
Closed

Comments

@paveliko
Copy link

paveliko commented Feb 2, 2014

Hi,

I need to use milliseconds in animations in my movie clips.
I try to pass { useTicks: false } param to get method of Tween object but it's not working.

I want to use milliseconds instead of 40 ticks.
How can I do it?

var stage = new createjs.Stage("canvas");
createjs.Ticker.addEventListener("tick", stage);

var mc = new createjs.MovieClip(null, 0, true);
stage.addChild(mc);

var shape= new createjs.Shape(new createjs.Graphics().beginFill("#999999").drawCircle(100, 100, 100));
mc.timeline.addTween(createjs.Tween.get(shape).to({x:0}).to({x:760}, 40).to({x:0}, 40));

mc.gotoAndPlay(0);
@danielocdh
Copy link

If using milliseconds isn't possible, is there a way to make the animation move through frames based on time instead of render speed? I want the animation to show at same speed regardless of device FPS

@gskinner
Copy link
Member

gskinner commented Oct 7, 2015

Timeline & tweens support time based animation, but at present MovieClip does not. This is mainly because Flash Pro (which is the primary use of MovieClip), only really supports a frame-based paradigm.

However, we recognized the need for time-synching MovieClip instances, and added support for it via the .framerate property (also available on Sprite), which keeps your clip running at that framerate regardless of the real-world framerate.

The tricky part of using it is that it has to be set on each MovieClip individually, it isn't inherited by child clips (unless they are in Graphic mode). I recently built a work around in AdHelper though, which you could grab. I'll be looking at building something similar into the library as well.

https://github.com/CreateJS/html5ads/blob/master/AdHelper/AdHelper.js#L283
http://createjs.com/html5ads/#Duration

I'm going to close this, and add an issue for the global setting specifically. I'm also open to feedback if you think MovieClip should support time based animations directly - it shouldn't be crazy hard to add if there's a genuine use case.

@gskinner gskinner closed this as completed Oct 7, 2015
@gskinner gskinner added enhancement and removed bug labels Oct 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants