Tips & Tricks 7: Create Popup Windows in Flash – ActionScript 3.0 July 14, 2009

Tips & Tricks 7: Create Popup Windows in Flash – ActionScript 3.0

by flashuser in ActionScript 3.0, Flash Tips & Tricks

A couple of days ago a fellow asked me how can he makes a popup window in Flash for his website. I showed him how and I was thinking why not to share with you also. It’s an easy and very powerfull trick.

Here we go (this example is for Actionscript 3.0):

1. Create a MovieClip and give an instance name (e.g: myMovie)

2. Add an event listener to the movie you created:

myMovie.addEventListener("mouseDown",mousePress);

3. Create the mousePress function like so:

function mousePress(e:MouseEvent){

var url ="javascript:window.open('http://www.yoursite.com','title',
'width=800,height=600,toolbar=no,resizable=no,menubar=no,
status=no,scrollbars=no');void(0);";

var request1:URLRequest = new URLRequest(url);

	try {
  navigateToURL(request1);
         }
      catch (e:Error) {
  trace("Error occurred!");
}
}

4. Publish the movie and preview it in your browser.

Subscribe to our RSS Feed and follow us on Twitter

Enjoy this post?

Help us grow this site and share the content with others among you.

img-delicious img-digg img-twitter
img-stumbleupon img-facebook img-mixx

Comments
  1. good stuff! thanks for the tip


  2. quick question: stated playing around with this, kicks out

    “1095: Syntax error: A string literal must be terminated before the line break.” regarding the var url string.

    also never seen “mousedown” as the event type. I’m used to addEventListener(MouseEvent.MOUSE_DOWN, mousePress)…. is that a different way to event type a listener?


  3. The error appears because I put two Enter keys in the attached string for “url” variable so all the example code to be displayed. When you test it in Flash write it in a single line. Also a “}” is missing for the function to be ended.

    For the MouseEvent you can use both the string like I do or the longer version, i’m used with the first one:)


  4. I added the missing bracket to the example code.


  5. cool, you learn something everyday: I never knew you could put a string as the Event type. Thanks.


  1. Daily Trick 7: Create Popup Windows in ActionScript 3.0 | Flash User | Adobe Tutorials

Leave a Comment

Note: You can get a Gravatar account for free so your avatar can be shown when you post a comment on any website that supports gravatars.