Jump to content
Search Community

TransformAroundPoint and Bezier Plugins

Arghya test
Moderator Tag

Recommended Posts

Is there any other way to do something like that????

I want to apply tween on a movieclip which is followed a curve path and i adjust the movieclip registration point externally.. so how can i do it using TweenMax???????????

Link to comment
Share on other sites

Is there any other way to do something like that????

I want to apply tween on a movieclip which is followed a curve path and i adjust the movieclip registration point externally.. so how can i do it using TweenMax???????????

Link to comment
Share on other sites

I think you could accomplish just about anything if you nest the target clip in another clip.

 

Lets say you want to rotate a box_mc while it is following a Bezier path

 

Place box_mc in parent_mc.

Set parent_mc as the target of your Bezier tween

Create a tween that rotates parent_mc.box_mc

  • Like 2
Link to comment
Share on other sites

 Nesting the clip inside a parent was my best advice as it allows you to offset the position of the child anywhere you want in relation to the parent. Try using the transformAroundPointPlugin on the child while the parent follows the bezier path.

Link to comment
Share on other sites

This code will make a red box appear to follow a Bezier path and scale (transform) around its bottom right corner. Just paste it in a blank fla that has access to the greensock classes.

 

import com.greensock.*;
import com.greensock.plugins.*;
import flash.display.Sprite;


TweenPlugin.activate([BezierPlugin, TransformAroundPointPlugin]);


//create a red box
var box:Sprite = createSquare(50);


//create a parent container (blue)
var parent_mc:Sprite = createSquare(10, 0x0000FF)


parent_mc.addChild(box);


//offset red box position - negative widht and height
box.x = - box.width;
box.y = - box.height;


//tween parent along bezier path
TweenMax.to(parent_mc, 10, {bezier:[{x:100, y:250}, {x:300, y:0}, {x:500, y:250}], repeat:-1});


//scale box around bottom right corner
TweenMax.to(box, 1, {transformAroundPoint:{point:new Point(0, 0), scaleX:0.2, scaleY:0.2}, repeat:-1, yoyo:true}); 




function createSquare(size:Number, color:uint=0xFF0000):Sprite {
    var s:Sprite = new Sprite();
    s.graphics.beginFill(color, 1);
    s.graphics.drawRect(0,0,size,size);
    s.graphics.endFill();
    this.addChild(s);
    return s;
}

In your production files you would make the blue parent have no width, height or color, I left it visible just so you can see that the parent follows the curve, and its child the redbox has a separate transform tween.

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.
×
×
  • Create New...