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:
- Create your Open Button and place it in a frame on the main timeline. Select it and give it an instance name of btnOpen.
- Create a movie symbol for your Popup Modal.
- Create your Close Button and place it in the Popup Modal movie. Select it and give it an instance name of btnClose.
- Add your movie to the main timeline. Select it and give it an instance name of modPopup.
- 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.