[Last Call] Learn how to a build a cloud-first strategyRegister Now


Flash 8, Simple JavaScript POPUP Window from button

Posted on 2009-04-29
Medium Priority
Last Modified: 2013-12-25
I am creating a Flash CD which will run from an autostart.  I am working in Flash 8.  At some point I will need to pass variables from an XML file that populate a scrolling MC.   These will be companies that are offering coupons.  Each company will have info about the company coming from the XML file.  There will be a Click to Print Coupon button next to each company.

For demonstration, I need to have the button open a pre-defined popup window which I will place the company info and a simple javascript print button.  Down the road I will need the popup to be populated by the variables in the MC.

Below is the action script code I have been monkeying with.  It doesn't open a popup it open a complete browser with no url (file name).

This popup function should have nothing to do with a browser.
on (release) {
getURL ("javascript:NewWindow=window.open('popup.htm','ne wWin','width=400,height=300,left=0,top=0,toolbar=N o,location=No,scrollbars=No,status=No,resizable=No ,fullscreen=No'); NewWindow.focus(); void(0);");

Open in new window

Question by:TecTaoMC
  • 3
  • 2

Accepted Solution

ccarey earned 1000 total points
ID: 24265778
Unfortunately if you are running this as a projector then you won't have Javascript available to you so that window.open will not function as expected. Javascript runs inside a browser only.

If you are not worried about mac compatibility, your easiest way through is to use an HTA wrapper. This is effectively an HTML file which will run as an application - borderless, fullscreen, whatever. Because it's a browser you also get the benefit of being able to launch popups and utilise javascript.

The basic setup involves creating your HTML, embedding the SWF as usual and then adding a HTA tag near the top inside the <head> tag. The file extension needs to be .hta

Here's a primer from Microsoft:

Alternately you may want to explore AIR for a bit of cross-platform compatibility action:

The attached snippet is an HTA app stub - it's set to run fullscreen with no borders. Save the contents into a file called "test.hta" and you can double-click to run. Alter the code to embed your SWF inside the body and you're done.
		<TITLE>My Monster Application</TITLE>
		 <!-- style the window -->
		embed your swf here

Open in new window


Author Comment

ID: 24266091
Thanks for getting back to me on this ccarey.  I read up on this and tried the code.  Didn't seem to work work after switching and making IE my default browser.  But with the limitation of only Microsoft and not Mac I'm going to have to look for another solution.

I believe it's not an HTML issue but a Flash Action Script issue that I need to explore.  The process for this CD is to allow a viewer to scroll particular businesses in a specific geo location.  The businesses for a particular category are loaded through an XML file containing the data.

Through a scrolling component, the viewer can look at all businesses.  Each business will offer savings through a printable coupon.  Next to the business is a button to print the coupon.

I've tried the popup which if I were doing this in PHP would be no problem.  I found and edited an action script that would load an external Movie Clip.

Any thoughts would be appreciated.


Expert Comment

ID: 24266444
The AIR solution will give you that cross-platform (mac/pc) functionality.

Without using a browser-based solution the closest you will get is

on (release) {
     getURL ('popup.htm','_blank');

Customising the window size and so forth requires javascript, which isn't available from a vanilla Flash projector. Calling just the URL you are interested in will at least give you the content you desire in a browser window.

Author Comment

ID: 24266962
ccarey, thanks again for your inmput.  I went back an re-read you notes from the first post and found I didn't save the html file as a HTA, when once I did, it opened to a full screen taking over my monitor window.  Had to such down and reboot since I couldn't get it to close.

I can see the following process.  There is an auto start on the CD that starts up a starter.exe file what auto starts and within a second opends the HTA html page with the flash swf files for the presentation.  Ihen useing javascript to open popups should work

Thanks for the time the now I have something new to familiarize myself with.


Expert Comment

ID: 24267075
alt+F4 to close it, or you can put a button in that executes a javascript:window.close()

You can actually just use the HTA as the target for the autorun, without the need for another EXE

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses
Course of the Month18 days, 6 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question