Traffic lights in an interactive pdf!

I was asked to create a traffic lights as an interactive object on a pdf file so the owner of the file could finalise the status of the document by clicking on different colour buttons like the image below.

Screen Shot 2014-11-12 at 12.30.37 pmI used a bit of Java Script to program the objects so they behave as I like. Details of how to this are as below:

  1. So the table has been designed in InDesign and despite of the header other fields have been left blank (we will do the text on pdf)
    First create a button over each filed so you will have 6.
  2. In the “General” menu of “Bottom Properties” name each filed as you like (e.g. Green, a, Yellow, b and Red, c)Screen Shot 2014-11-12 at 12.37.03 pm
  3. In the “Appearance” menu assign the preferred colours (you can use Grey scale, RGB, CMYK or HSB Sliders to chose the colours)Screen Shot 2014-11-12 at 12.37.14 pmScreen Shot 2014-11-12 at 1.05.08 pm
  4. For the each bottoms at the top row in “Actions” menu add the Java Script action as shown below:Screen Shot 2014-11-12 at 12.38.01 pmScreen Shot 2014-11-12 at 12.45.48 pm
    Green button:
    var a = this.getField(“a”);
    var b = this.getField(“b”);
    var c = this.getField(“c”);
    a.fillColor = color.green;
    b.fillColor = color.white;
    c.fillColor = color.white;
    Yellow button:
    var a = this.getField(“a”);
    var b = this.getField(“b”);
    var c = this.getField(“c”);
    a.fillColor = color.white;
    b.fillColor = color.yellow;
    c.fillColor = color.white;
    Red button:
    var a = this.getField(“a”);
    var b = this.getField(“b”);
    var c = this.getField(“c”);
    a.fillColor = color.white;
    b.fillColor = color.white;
    c.fillColor = color.red;
  5. If you want to use RGB or CMYK values or even transparent colour you could use codes in below samples:
    c.fillColor = [“CMYK”,1,0,0,0 ]; (Cyan colour for box c)
    c.fillColor = [“RGB”,0,0,1 ]; (Blue colour for box c)
    c.fillColor = [“T”]; (transparent colour for box c)

Tip: Do not forget “;” at the end of each line!

Note: the featured image is the Traffic Lights tree and is from wikipedia.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s