ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Attach an image next to animated numbers counting up

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Guliano Di Tommaso
Attach an image next to animated numbers counting up
on Nov 22, 2017 at 11:55:00 pm

Hello everyone.

I'm having a little problem i can't seem to resolve efficiently.

Right now I'm using a common expression with slider control to create a simple counter, with a "$" attached next to it:

Math.round(effect("Slider Control")("Slider")) + "$";


So, for example, if my number starts at 0 and ends at 50000, then the "$" will have moved a few spaces to the right, like this:



As you can see, the "$" moves back and forth while the number changes and then it ends more to the right because the number increased.

This happens automatically attaching "$" to the expression. I want to achieve the same but with a little image. Lets say that instead of a $ sign i want to attach a little image of a coin, or a gem, etc, and i want it to move accordingly next to the number when it increases.



On an ideal world, there would exist some way to call the image directly inside the expression, like ' + "image path"; '

but that's not the case here i guess 😃


**Please ignore the next paragraphs if you have a better idea**
I though about adding a dot or something next to the number, and then track the movement it does (because it will move when the number grows bigger) so i could later attach it to a null object and finaly link the null object with the image, but that idea has 2 problems:

1) i can't track my text layer, it seems after effects only lets you make trackings of places inside a video file and
2) i would have to be extra careful covering the dot/symbol i will be using the tracking over. Sometimes the image won't be a coin, and it may present obstacles for covering it properly


I'm really looking forward to your suggestions and sorry for my grammar mistakes, i'm not a native english speaker.

Thanks in advance!


Return to posts index

Dan Ebberts
Re: Attach an image next to animated numbers counting up
on Nov 23, 2017 at 5:33:25 pm

Something like this maybe:

L = thisComp.layer("Numbers");
gap = 10;
r = L.sourceRectAtTime(time,false);
x = L.toComp(L.anchorPoint + [r.left+r.width,0])[0] + gap + width/2;
[x,value[1]];



Dan



Return to posts index

Guliano Di Tommaso
Re: Attach an image next to animated numbers counting up
on Nov 23, 2017 at 8:14:51 pm

Hi Dan, thanks for your answer.

I tried your expression but it only works when the numbers move from position, but not really when they increase.

I did this gif to show you what i mean:




Maybe if the expression is based on the width or lenght of the text layer or anything like that? Is something like that possible or what other solution might do?

Thanks in adavnce


Return to posts index


Dan Ebberts
Re: Attach an image next to animated numbers counting up
on Nov 23, 2017 at 9:06:52 pm

Try it this way:

L = thisComp.layer("Numbers");
gap = 10;
r = L.sourceRectAtTime(time,false);
x = (L.position - L.anchorPoint + [r.left+r.width,0])[0] + gap + width/2;
[x,value[1]];


Dan



Return to posts index

Guliano Di Tommaso
Re: Attach an image next to animated numbers counting up
on Nov 23, 2017 at 9:55:26 pm

Hi again Dan, i don't want to be annoying but it doesn't work either. I think i'm a bit closer to what's going on though.

I searched about sourceRectAtTime() and sourceRectAtTime().width and i kinda understand your expression.

I did a quick test, and it seems that the expression recognizes the width of the text layer but not the modification of the width property done by the slider control and the numbers it changes.

If i use your expression, and then i type manually, then it works. The image moves accordingly.

But if the slider control does the change (increase the numbers and therefore change the width) then it doesn't recognize the text layers correct width. I made a quick 34 sec video to show you what i mean, sorry for the hassle







Return to posts index

Dan Ebberts
Re: Attach an image next to animated numbers counting up
on Nov 23, 2017 at 10:54:19 pm

Interesting. It works for me with the slider or typing the numbers in. I'm not sure what the difference is in our setups.

Dan



Return to posts index


Guliano Di Tommaso
Re: Attach an image next to animated numbers counting up
on Nov 23, 2017 at 11:19:13 pm

Oh no ☹

Are you using the same expression as me for the slider?

Math.round(effect("Slider Control")("Slider")) + "$";


Return to posts index

Dan Ebberts
Re: Attach an image next to animated numbers counting up
on Nov 24, 2017 at 12:08:01 am

I didn't have the + "$" in there, but I just tried it and it works for me.

Dan



Return to posts index

Guliano Di Tommaso
Re: Attach an image next to animated numbers counting up
on Nov 24, 2017 at 1:43:13 am

Okay Dan, thanks a lot so far for your replies. This will be my last try.

I hope it is not too much to ask, but would you please try opening the after effect project that i'm using? It has 2 layers, the numbers layer and the image, just as it is in the video i uploaded.

If the same project and file works for you, then i'll know that the problem is in my setup and i'll discard the idea of doing this.

I uploaded a .rar file with the AE project file and the tiny image

11895_aeprojectandimage.rar.zip

In case you can do it, thanks a lot. If not, thanks too, you've answered a lot


Return to posts index


Dan Ebberts
Re: Attach an image next to animated numbers counting up
on Nov 24, 2017 at 4:53:34 am

I can observe the problem, but I can't figure out why it's happening.

If I create a new text layer at the top of layer stack, add a slider to it, copy the keyframes from your text layer, and then change the new layer's name to "Numbers", the graphic jumps to the new text layer and behaves properly as the slider value advances. So I think there is something unusual about your text layer, but I don't know what it is.

Dan



Return to posts index

Guliano Di Tommaso
Re: Attach an image next to animated numbers counting up
on Nov 24, 2017 at 5:05:54 am

Dan, you are absolutly right! I tried the same and it worked!

On a new layer, everything works. It is crazy, i'll leave it like that and re-do everything.

Thanks again for your replies during the whole day! 😁


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]