Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random Hexadecimal with 6 characters

  • Random Hexadecimal with 6 characters

    Posted by Stuart Paciej on October 23, 2014 at 11:30 am

    Hi I want to generate a random set of characters with the prefix ‘x.’

    So for example successive frames it could be
    ‘x.AC34CD’
    ‘x.B7A4ED’
    ‘x.F4300C’
    etc.

    I’m using this expression attached.

    Which only gives me 1 character, e.g. ‘x.C’

    I do try but my expression language is pretty crappy. Thanks!

    S

    hex = String.fromCharCode(65 + Math.floor(random(6)));
    var myLayerIndex = 3
    "x." + hex

    Stuart Paciej replied 11 years, 6 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    October 23, 2014 at 2:03 pm

    Try this:

    i = Math.floor(random(16777216));
    “x”+(“000000” + i.toString(16)).substr(-6);

    Dan

  • Stuart Paciej

    October 28, 2014 at 9:26 am

    Thank you Dan! I have another expression question for you but its completely unrelated so I’ll start a new topic.

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