Home / Articles / Adding Basic Interactivity in Adobe Edge Animate

Adding Basic Interactivity in Adobe Edge Animate

Article Description

Learn how to use Adobe Edge Animate’s built-in code snippets and intuitive panels to add actions to create engaging, user-driven, interactive experiences.
Creating the buttons

Creating the buttons

A button is a basic visual indicator of what the user can interact with. The user usually clicks a button, but many other types of interactions are possible. For example, rollovers, double-clicks, and rollouts are all possible. Edge Animate also provides events unique to mobile devices, such as touches.

You’ll start with the simplest, and most common event, which is the single-click.

Adding the thumbnails

Small, cropped versions of the larger Myanmar images are provided for you in the images folder.

  1. In the Library panel, expand the images folder within the Assets folder.
  2. Drag the file called button1_gray.jpg from the Library panel to the Stage.
  3. A grayscale thumbnail of a fisherman appears on the Stage, Timeline, and Elements panel.

  4. Position the thumbnail so that its top-left corner is at the top-left corner of the Stage. The coordinates should be at X=0, Y=0.
  5. Drag the file called button2_gray.jpg from the Library panel to the Stage, and position it just below the first thumbnail. You can use the smart guides to help automatically snap the images in place. The coordinates should be at X=0, Y=80.
  6. Two grayscale thumbnails are at the left side of the Stage, one above the other.

  7. Drag the remaining three grayscale thumbnails from the Library panel onto the Stage, positioning each successive one below the previous one.
  8. There should be a total of five thumbnail images vertically stacked on the left side of the Stage.

Adding the events

Each element on the Stage can have its own events and actions. Insert code for individual elements from the far-left column of the Timeline or Elements panel. The Open Actions button is indicated by a set of curly braces.

  1. In the Timeline or the Elements panel, click the Open Actions button for the first thumbnail element, button1_gray.
  2. The script panel for button1_gray opens.

    A menu of options automatically opens, displaying the events that are possible for the button1_gray element.

  3. Select the first option: click.
  4. Edge Animate adds a click tab at the top of the panel with an empty script pane and available snippets on the right.

Adding the actions

Each event must have an accompanying action, or a response, to the event.

  1. Position your cursor on the second line of the script pane (after the first line of comments), and choose the Stop at option.
  2. Edge Animate adds the code to stop the playhead at a particular position on the Timeline.

  3. In between the parentheses of the stop() method, replace the 1000 number with 0.
  4. The stop() method requires a number, in milliseconds, of the point on the Timeline at which it will move to and stop. Since this first grayscale thumbnail is of the fisherman, you want the playhead to stop at 0:00 seconds, the point at which we see the full image of the fishermen on the Stage.

  5. Close the script panel.
  6. The Open Actions icon for the button1_gray element becomes filled in, indicating that there is currently script attached to that element.

  7. Preview your Edge Animate composition in a browser by selecting File > Preview in browser, or pressing Ctrl+Enter (Windows)/Command+Return (Mac OS).
  8. At any point during the slideshow, click the first grayscale thumbnail.

The slideshow stops and shows the image of the fishermen.

Completing the interactivity

Now that you’ve completed the interactivity for the first button, add the same functionality to the remainder.

  1. In the Timeline or the Elements panel, click the Open Actions button for the second thumbnail element, button2_gray.
  2. The script panel for button2_gray opens.

  3. Click on the Plus button on the upper-left corner.
  4. A menu of options opens, displaying the events that are possible for the button2_gray element.

  5. Select the first option: click.
  6. Edge Animate adds a click tab at the top of the panel with an empty script pane and available snippets on the right.

  7. Position your cursor on the second line of the script pane (after the first line of comments), and choose the Stop at option.
  8. Edge Animate adds the JavaScript code to stop the playhead at a particular position on the Timeline.

  9. In between the parentheses of the stop() method, replace the 1000 number with 2000.
  10. The stop() method requires a number, in milliseconds, of the point on the Timeline at which it will move to and stop. Since the second grayscale thumbnail is of the statues, you want the playhead to stop at 0:02 seconds, the point at which we see the full image of the statues on the Stage.

  11. Add similar click events to all the other grayscale thumbnail images, with the Stop at option. Be sure to change the arguments for each stop() method as follows, so the playhead stops at different times to display a unique larger image on the Stage:
    • The stop() method for button1_gray should go to 0 milliseconds.
    • The stop() method for button2_gray should go to 2000 milliseconds.
    • The stop() method for button3_gray should go to 4000 milliseconds.
    • The stop() method for button4_gray should go to 6000 milliseconds.
    • The stop() method for button5_gray should go to 8000 milliseconds.
7. Events and actions | Next Section Previous Section