Skip to main content
Participant
April 22, 2024
Answered

how to add a multiplication condition to the after effect counter?

  • April 22, 2024
  • 1 reply
  • 607 views

Greetings to all! I added an expression to my project, thanks to which, when a certain value is selected on the control (slider), the symbol at the beginning of the amount changes, the amount itself as a counter. So, since I don't understand anything in the code, I can't figure out how to add an additional condition to this code, in which, along with the sign change, the amount in the counter will be multiplied by a single digit. For example, in the currency "$" the amount is 20,000, and in the currency "S/" 20,000 should be multiplied by 7, and so on with the rest of the characters. Is it really possible to do this? I will be infinitely grateful for the tips

This topic has been closed for replies.
Correct answer Dan Ebberts

For a situation where each country has their own currency symbol, thousands seperator, and multiplier, I think I'd structure it like this:

geo = Math.round(comp("Main Comp").layer("GEO").effect("GEO")("Slider"));
switch(geo){
  case 1:
    symbol = "$";
    mult = 1;
    sep = ","
    break;
  case 2:
    symbol = "S/";
    mult = 7;
    sep = "";
    break;
  default:
    symbol = "";
    mult = 1;
    sep = "";
    break;
}
num = ((comp("Main Comp").layer("History Bet 1").effect("Win amount")("Slider").value*mult).toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, sep));
symbol + " " + num

You'd need to add additionl cases 3,4,5 and 6 (and check case 2).

 

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
April 22, 2024

For a situation where each country has their own currency symbol, thousands seperator, and multiplier, I think I'd structure it like this:

geo = Math.round(comp("Main Comp").layer("GEO").effect("GEO")("Slider"));
switch(geo){
  case 1:
    symbol = "$";
    mult = 1;
    sep = ","
    break;
  case 2:
    symbol = "S/";
    mult = 7;
    sep = "";
    break;
  default:
    symbol = "";
    mult = 1;
    sep = "";
    break;
}
num = ((comp("Main Comp").layer("History Bet 1").effect("Win amount")("Slider").value*mult).toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, sep));
symbol + " " + num

You'd need to add additionl cases 3,4,5 and 6 (and check case 2).

 

Participant
April 23, 2024

I am incredibly grateful to you! What you suggested works like a Swiss watch. I hope that one day I will be in your place to help aspiring workers.