First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Jeffrey F. Hill | Website: http://www.flash-db.com

Adding custom text, message's, and Links to your Popup window with JavaScript + PHP

This is where we get a little bit more technical and use a little bit of PHP - The php used in this example is so simple though that you should be able to convert it over to ASP or CFM with little or no experience in either. Please note that PHP or any other server side scripting language is not needed before this section. And can be avoided all together with the document.write function in JavaScript.

Here's the basic code used when we open the popup window:

on (release) {
getURL ("javascript:NewWindow=window.open('ShowPopup.php?customName=Jeff&customLink=http://www.flashkit.com&
customMessage=This is my Custom Message','newWin','width=400,height=300,left=0,top=0,toolbar=No,location=No,scrollbars=No,
status=No,resizable=No,fullscreen=No');  NewWindow.focus();     void(0);");

The part in red is the only part where changing from the original 'basic' code. What where doing here is attaching variables onto the end of the URL string. Then we embed the Flash movie in a php page (which is the same as html, with the exception that we can add scripting to it). The PHP file would contain the following code in any part before we embed the movie:

What this does is to grab the variables indicated with a preceding $ sign from the URL - then put them into a format we can attach onto the end of the SWF embed tags. The $Attach variable is used to store all of them.

The embed code for the Flash movie would then look like this:

 quality=high bgcolor=#0066CC  WIDTH=820 HEIGHT=640 TYPE="application/x-shockwave-flash" 

The most important part of the above embed code is indicated in Red. This will just print out the variables that we earlier defined with the $Attach variable onto the end of the flash movie. These variables will automatically be declared in the movie. Theirfor all you have to do to the Flash movie in order to see your custom text is to create a dynamic text field named for example 'customName' or 'customMessage'. For the link to work all you need to do after this is to create a button and add the following code:

on (release) {
	getURL (customLink, "_blank");

The red part indicates the variable you attached to the Flash movie in the embed code.

And that's about it. You can actually create some fairly advanced applications with all these mentioned procedures and functions.

» Level Intermediate

Added: 2002-01-09
Rating: 9 Votes: 149
(10 being the highest)
» Author
Jeffrey Hill is a freelance web developer from Boulder, Colorado. He specializes in creating and developing dynamic database driven Flash content and applications. Specialty's include SQL, PHP, Perl, and XML.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.