Flash CS5 Popup Modals

Do you want to have a button in your Flash CS5/5.5 project that when clicked, opens a popup modal (or popup window, if you prefer) which has its own close button? Here’s what you do:

  1. Create your Open Button and place it in a frame on the main timeline. Select it and give it an instance name of btnOpen.
  2. Create a movie symbol for your Popup Modal.
  3. Create your Close Button and place it in the Popup Modal movie. Select it and give it an instance name of btnClose.
  4. Add your movie to the main timeline. Select it and give it an instance name of modPopup.
  5. Add the code below to an Action layer in the main timeline

import flash.events.MouseEvent;

modPopup.visible = false;

btnOpen.addEventListener(MouseEvent.CLICK, showPopup);

function showPopup(event:MouseEvent):void
{
modPopup.visible = true;
}

modPopup.btnClose.addEventListener(MouseEvent.CLICK, hidePopup);

function hidePopup(event:MouseEvent):void
{
modPopup.visible = false;
}

Save your project and test your movie.

Leave a Reply

Your email address will not be published. Required fields are marked *