Jump to content
GreenSock

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

variables in attributes

Recommended Posts

Hi,

 

How can I use a variable in the d section of this tween?

TweenMax.to("#pole",force,{attr:{d:'M100,300 C100,100 110,40  110,40'},repeat:-1,yoyo:true});

I tried 

TweenMax.to("#pole",force,{attr:{d:'M100,300 C100,100' +force+',40'  +force+',40'},repeat:-1,yoyo:true});
Link to comment
Share on other sites

This works:

var curve = {d:'M100,300 C100,100 ' + force +',40  ' + force +',40'};

TweenMax.to("#pole",force,{attr:curve,repeat:-1,yoyo:true});
Link to comment
Share on other sites

Hello gareth,

 

Looks like you were missing the space between the C100,100 and the first single quote '.

 

d:'M100,300 C100,100SPACE' +force+',40' +force+',40'

// So this
TweenMax.to("#pole",force,{attr:{d:'M100,300 C100,100' +force+',40' +force+',40'},repeat:-1,yoyo:true});

// Becomes this:
TweenMax.to("#pole",force,{attr:{d:'M100,300 C100,100 '+force+',40' +force+',40'},repeat:-1,yoyo:true});

:)

  • Like 2
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.
×