Jump to content
Search Community

Using Variables in an Object Name

Greg Stager test
Moderator Tag

Recommended Posts

I am having a little trouble working a variable into an object name.

For instance, suppose I have 30 boxes named box1alpha, box2alpha, box3alpha, etc.

I have tried to drop a variable in the middle of an object name and it seems to work the first time but when the variable is changed it doesn't.

 

In the codepen - I am expecting each box to move down with each click as the num variable is incremented.

How can I get the animation to read the new variable on subsequent plays?

 

See the Pen mdPrNrz?editors=1111 by Arelwynn (@Arelwynn) on CodePen

Link to comment
Share on other sites

You can just use a functions and loops to do the heavy lifting for you. You can even use a global vars object of values and pass it to the tweens if that works in your situation. If you want to share more, maybe we can point you in the right direction.

 

Happy tweening.

:)

 

  • Like 1
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...