Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression needed! Thanks:)

  • Expression needed! Thanks:)

    Posted by Bojan Drobnjak on January 24, 2013 at 4:41 pm

    Hey guys, I am in need of some help. I am looking for an expression that will do the following for me:

    I am making a TV crawl (it is showing stock exchange graphics) and what I need is, once I paste this text into AE layer “Bank TWO 245 %+%”
    I’d like to have the character ‘+’ automatically replaced with an image of a green up arrow. Also, if i paste “Bank ONE 424 %-%” I’d like to have
    the character ‘-‘ automatically replaced with an image of a red down arrow. If its possible to do it, it would save me lots of time.

    I’d be gratefull if a kind soul would help out 😉 Thank you!

    ps.
    English is not my native language, so I’m sorry if my explanation isnt clear enough.
    ps.2
    I am also very new to expressions, so have mercy! 😀

    Bojan Drobnjak replied 13 years, 6 months ago 2 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    January 24, 2013 at 5:33 pm

    I can’t think of a good way to do that with images. If you could find a font with acceptable up and down arrow characters, you could use a source text expression like this to convert the “+” and “-” characters:


    s = "";
    for (i = 0; i < value.length; i++){
    if (value[i] == "+")
    s += String.fromCharCode(0x2191)
    else if (value[i] == "-")
    s += String.fromCharCode(0x2193)
    else
    s += value[i];
    }

    Than you could add a fill color animator set to red, add an expression selector, delete the range selector and add an Amount expression like this for the expression selector:

    s = text.sourceText;
    if (s[textIndex-1] == String.fromCharCode(0x2193)) 100 else 0

    Then add another fill color animator set to green and do the same as above except use this expression:

    s = text.sourceText;
    if (s[textIndex-1] == String.fromCharCode(0x2191)) 100 else 0

    Something like that.

    Dan

  • Bojan Drobnjak

    January 25, 2013 at 3:24 pm

    Thanks for the reply Dan.

    It seems to work, at least partially. The green/red signs do not render out until I actually double click the text layer. The rest works pretty nice 🙂

    https://i.imgur.com/swE5ikZ.jpg

    ps. would it be possible for the expression to call for a composition (which will contain an arrow)? instead of an image

    View post on imgur.com

  • Dan Ebberts

    January 25, 2013 at 7:43 pm

    I’m not sure what you mean by “call”, but I’m pretty sure the answer is no.

    You could do what you’re trying to using a script to align multiple text layers and images. The only way I know of to do it with an expression would be to use the sampleImage() hack, which generally has a huge impact on performance.

    Dan

  • Bojan Drobnjak

    January 25, 2013 at 10:35 pm

    I meant to say if it would be posible to use a comp or a layer with an image to achieve something similar. Could I have two layers (red arrow and green arrow), both hidden, and then after I paste the text the expression would control the opacity or visibility of the layer. – would make the red layer visible and + would make the green layer visible

  • Dan Ebberts

    January 25, 2013 at 11:03 pm

    You could do that with an opacity expression like this for “+”:

    s = thisComp.layer(“Your Text Layer”).text.sourceText;
    s.indexOf(“+”) < 0? 0 : 100

    and like this for “-“:

    s = thisComp.layer(“Your Text Layer”).text.sourceText;
    s.indexOf(“-“) < 0? 0 : 100

    Dan

  • Bojan Drobnjak

    January 26, 2013 at 12:06 pm

    Excellent mate, thank you! How much are you payed for this forum tutoring? 😀

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy