Jump to content

Search In
  • More options...
Find results that contain...
Find results in...

LinePath2D with rotation value per frame

Recommended Posts

Would you consider updating the class by including more data from the fl.motion:KeyFrameBase (http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/motion/KeyframeBase.html ), specifically :

  • rotationConcat
  • color
  • alpha

I was considering using Tweenlite for my Starling game. Llevels are imported from swf and then parsed during runtime. Those levels contain movieclips with motion tweens (+ rotation along the path).  


With tweenlite it's possible to rotate only one way or another, not have a rotation value per each frame, not to mention other things like color values.

Link to comment
Share on other sites

I'm having a tough time understanding the goal here or what the perceived limitation is - were you under the impression that you could not sequence various states (color tweens, alpha tweens, rotation, etc.) at various points during the animation? You certainly should be able to, and TimelineLite (or TimelineMax) makes it pretty easy. 


You can set useFrames:true for any timeline or tween to make it use frames instead of seconds. 


Maybe it'd help if you described (or showed) a particular thing that you don't think is currently possible with GSAP and then we can take a crack at helping. 

Link to comment
Share on other sites

I extract motion data (as array of keyFrameBase objects) from an imported swf clip during runtime. 


That data contains all changes per each frame.  


Yes, with TimelineLite I can animate from point A to point B on various params, but I need more granular control for each frame, e.g. rotation  is different in each frame.


LinePath2D does that but only for (x,y) , not other motion tween params. 


Maybe there's a way to animate according to motion tween data that I just missed somehow? 

Link to comment
Share on other sites

Maybe I'm still misunderstanding something here, but aren't you just talking about sequencing some tweens (on whatever properties you want)? For example:

//let's say you've got an array of 10 rotations, one for each frame
var rotations:Array = [0,10,20,30,40,50,60,70,80,90];

//and you want to build out the animation in a frame-based way:
var tl:TimelineLite = new TimelineLite({useFrames:true});
tl.set(mc, {rotation:rotations[0]}); //starting position
for (var i:int = 1; i < rotations.length; i++) {
    tl.to(mc, 1, {rotation:rotations[i]); 

That'll make mc.rotation iterate from 0 to 90 in increments of 10 over the course of 10 frames. You're literally building every keyframe into the timeline, and it's perfectly sequenced and synchronized so that you can run that timeline in any direction, seek(), or whatever. 


Does that help? 

Link to comment
Share on other sites

Yes, something like that! Now how do I combine that with other tween properties like change in (x,y) position ? 

Link to comment
Share on other sites

Easy. Assuming you've got the data stored in keyframe objects of some kind that are in an array and each element has a "rotation" and "x" and "y" property (or whatever), you could do:

var keyframes:Array = [{x:100, y:200, rotation:0},{x:150, y:250, rotation:10}, ...]; //your data

var tl:TimelineLite = new TimelineLite({useFrames:true});
tl.set(mc, {x:keyframes[0].x, y:keyframes[0].y, rotation:keyframes[0].rotation}); //starting positions
for (var i:int = 1; i < keyframes.length; i++) {
    var keyframe = keyframes[i];
    tl.to(mc, 1, {x:keyframe.x, y:keyframe.y, rotation:keyframe.rotation}); 

Is that what you're looking for? 

Link to comment
Share on other sites

Yes, as I've written in the first post there's an array of KeyframeBase objects with each of them containing one keyframe data.  Thanks, I'll try that out!


Is there a way to control/set framerate for individual timeline?

Link to comment
Share on other sites

Well, the timeline will run at whatever your swf is running at by default, but you can certainly alter the timeScale() if you want. 

timeline.timeScale(0.5); //half speed
timeline.timeScale(2); //double-speed
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.