This is a very simple tutorial that gives you one simple thing to learn.

  • Calling the JavaScript function with arguments.
Take a look at the final version. I am sure you've seen this alot. Unfortunately, there might be some computers that won't allow the new popup due to the popup blockers, and I do not know of any way to circumvent that problem.
Here is the ActionScript part.
  1. siteName1 = "http://www.FlashVacuum.com";
  2. w1 = 780;
  3. h1 = 550;
  4. siteName2 = "http://www.ActionScript.org";
  5. w2 = 600;
  6. h2 = 400;
  7. this.launch1_btn.onRelease = function ()
  8. {
  9. trace("siteName1 = " + siteName1);
  10. getURL("javascript:launchMyWindow('" + siteName1 + "','" + w1 + "','" + h1 + "');");
  11. }
  12. this.launch2_btn.onRelease = function ()
  13. {
  14. trace("siteName2 = " + siteName2);
  15. getURL("javascript:launchMyWindow('" + siteName2 + "','" + w2 + "','" + h2 + "');");
  16. }
Line 1 ~ 7 siteName1 = "http://www.FlashVacuum.com";
w1 = 780;
h1 = 550;

siteName2 = "http://www.ActionScript.org";
w2 = 600;
h2 = 400;
I am sure you know what those lines are for. I am merely defining several variables that I can use for each button when it needs to call the JavaScript function.
Line 9 ~ 13 this.launch1_btn.onRelease = function ()
{
trace("siteName1 = " + siteName1);
getURL("javascript:launchMyWindow('" + siteName1 + "','" + w1 + "','" + h1 + "');");
}
This is where I am defining the action to the first button. Mind you that I am using the onRelease function rather than attaching the action to the button directly. I am doing this so that I know where all my codes are, which is the frame 1 of my movie. It is whole lot easier this way to manage the movie especially when you have more complex movie structure.
Two thing you will need to make sure of. Make sure of the quotes that you are using. Double quotes are for Flash and single quotes are for JavaScript. Another thing is that you've got to use onRelease rather than onPress to avoid the erratic behavior of the Google popup blocker.
Here is the JavaScript function.
  1. <script language="JavaScript">
  2. <!--
  3. function launchMyWindow(site, w, h)
  4. {
  5. // alert('site = ' + site + ' w = ' + w + ' h = ' + h);
  6. window.open(site,'','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=' + w + ', height=' + h + ', left=50, top=50');
  7. }
  8. -->
  9. </script>
Line 5 alert('site = ' + site + ' w = ' + w + ' h = ' + h);
I HAD used this alert() function to make sure that I am getting the right value from the Flash. It's always a good idea to use that function when you test your code and simply disable it when you are deploying the file.
Line 6 window.open(site,'','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=' + w + ', height=' + h + ', left=50, top=50');
This is the actual line which opens up a new window with three arguments, URL, width and height of the new window.
Well, that's about it, I guess. See if you can understand what I just said and post the question to the forum if you have any or if you have suggestion/correction.