I got this question in email and decided to answer it here as someone else may need it in the future as well. The question is:
my question is - how did you call the as3 in other window and how did you make it to be smaller and what code did you use for the button "close this window"?.
PLease answer me, I need to add an extra page with action script 3 to my web site that was made with action script 2.
Thank you in advance.
Basically I created the Flash file I needed with the AS3 code. In other words there was no "calling" the AS3. I just created an AS3 flash file. In my case the Flash File was named alaronMap3-e.swf and published it as an AS3 file and included the HTML page in my publish settings.
To pop open the new window, for the Map & Directions button I used the following AS2 code (since the button was on an AS2 file):
map.onRelease = map.onReleaseOutside=function () {
import flash.external.ExternalInterface;
if (ExternalInterface.available) { ExternalInterface.call("window.open", "http://www.alaron-nuclear.com/alaronMap3-e.html", "win", "height=500,width=680,toolbar=no,scrollbars=yes"); }
};
- map.onRelease = map.onReleaseOutside=function () {
- import flash.external.ExternalInterface;
- if (ExternalInterface.available) { ExternalInterface.call("window.open", "http://www.alaron-nuclear.com/alaronMap3-e.html", "win", "height=500,width=680,toolbar=no,scrollbars=yes"); }
-
- };
"map" is the instance name of my Map & Directions button and obviously you would replace my link with the link to your page.
For the Close this Window button in alaronMap3-e.html I just inserted a simple javascript:
<A href="javascript: self.close ()">Close this Window</A>
- <A href="javascript: self.close ()">Close this Window</A>
-
The HTML code to display the AS3 file is nothing more than what was generated when I published it with the addition of the close window link.
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Alaron Map and Directions</title>
<script language="javascript"> AC_FL_RunContent = 0; </script>
<script language="javascript"> DetectFlashVer = 0; </script>
<script src="AC_RunActiveContent.js" language="javascript"></script>
<script language="JavaScript" type="text/javascript">
<!--
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Revision of Flash required
var requiredRevision = 45;
// -----------------------------------------------------------------------------
// -->
</script>
</head>
<body bgcolor="#ffffff">
<!--url's used in the movie-->
<!--text used in the movie-->
<script language="JavaScript" type="text/javascript">
<!--
if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
alert("This page requires AC_RunActiveContent.js.");
} else {
var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
if(hasRightVersion) { // if we've detected an acceptable version
// embed the flash movie
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0',
'width', '632',
'height', '400',
'src', 'alaronMap3-e',
'quality', 'high',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'false',
'scale', 'showall',
'wmode', 'window',
'devicefont', 'false',
'id', 'alaronMap3-e',
'bgcolor', '#ffffff',
'name', 'alaronMap3-e',
'menu', 'true',
'allowScriptAccess','sameDomain',
'allowFullScreen','false',
'movie', 'alaronMap3-e',
'salign', ''
); //end AC code
} else { // flash is too old or we can't detect the plugin
var alternateContent = 'Alternate HTML content should be placed here.'
+ 'This content requires the Adobe Flash Player.'
+ '<a href=http://www.macromedia.com/go/getflash/>Get Flash</a>';
document.write(alternateContent); // insert non-flash content
}
}
// -->
</script>
<noscript>
// Provide alternate content for browsers that do not support scripting
// or for those that have scripting disabled.
Alternate HTML content should be placed here. This content requires the Adobe Flash Player.
<a href="http://www.macromedia.com/go/getflash/">Get Flash</a>
</noscript>
<br />
<div width="550" style="text-align:center;">
<A href="javascript: self.close ()">Close this Window</A>
</div>
</body>
</html>
- <html lang="en">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <title>Alaron Map and Directions</title>
- <script language="javascript"> AC_FL_RunContent = 0; </script>
- <script language="javascript"> DetectFlashVer = 0; </script>
- <script src="AC_RunActiveContent.js" language="javascript"></script>
- <script language="JavaScript" type="text/javascript">
- <!--
- // -----------------------------------------------------------------------------
- // Globals
- // Major version of Flash required
- var requiredMajorVersion = 9;
- // Minor version of Flash required
- var requiredMinorVersion = 0;
- // Revision of Flash required
- var requiredRevision = 45;
- // -----------------------------------------------------------------------------
- // -->
- </script>
- </head>
- <body bgcolor="#ffffff">
- <!--url's used in the movie-->
- <!--text used in the movie-->
- <script language="JavaScript" type="text/javascript">
- <!--
- if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
- alert("This page requires AC_RunActiveContent.js.");
- } else {
- var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
- if(hasRightVersion) { // if we've detected an acceptable version
- // embed the flash movie
- AC_FL_RunContent(
- 'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0',
- 'width', '632',
- 'height', '400',
- 'src', 'alaronMap3-e',
- 'quality', 'high',
- 'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
- 'align', 'middle',
- 'play', 'true',
- 'loop', 'false',
- 'scale', 'showall',
- 'wmode', 'window',
- 'devicefont', 'false',
- 'id', 'alaronMap3-e',
- 'bgcolor', '#ffffff',
- 'name', 'alaronMap3-e',
- 'menu', 'true',
- 'allowScriptAccess','sameDomain',
- 'allowFullScreen','false',
- 'movie', 'alaronMap3-e',
- 'salign', ''
- ); //end AC code
- } else { // flash is too old or we can't detect the plugin
- var alternateContent = 'Alternate HTML content should be placed here.'
- + 'This content requires the Adobe Flash Player.'
- + '<a href=http://www.macromedia.com/go/getflash/>Get Flash</a>';
- document.write(alternateContent); // insert non-flash content
- }
- }
- // -->
- </script>
- <noscript>
- // Provide alternate content for browsers that do not support scripting
- // or for those that have scripting disabled.
- Alternate HTML content should be placed here. This content requires the Adobe Flash Player.
- <a href="http://www.macromedia.com/go/getflash/">Get Flash</a>
- </noscript>
- <br />
- <div width="550" style="text-align:center;">
- <A href="javascript: self.close ()">Close this Window</A>
- </div>
- </body>
- </html>