Problem loading AS3 swf into AS2 swf.

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

I have an AS3 swf that works perfectly independently, but when I try to load it into an AS2 swf where I need it to display, it loads, but none of the AS3 code works.

I've read a few search results that seem to indicate that there's no way to do this and that I'm basically faced with converting the whole site to AS3.

Can someone confirm if this is the case? Or is there a way to do this. I found This Post by senocular regarding LocalConnection, but the way I'm reading that, I don't think that will help. I'm not trying to share info between the files. Just trying to load it and have it work properly.

Working file:
http://www.alaron-nuclear.com/devsite/S ... ap3-e.html

Broken file: (click the Map & Directions link on the top right)
http://www.alaron-nuclear.com/devsite/S ... ndpcb.html

The code that loads the movie in the AS2 file follows:
Code: [ Select ]
MovieClip.prototype.initiateRollOvers2 = function() {
    this.onRollOver = function() {
        this.gotoAndPlay("2");
    };
    this.onRollOut = this.onDragOut=function () {
        this.gotoAndPlay("6");
    };
};
var nav = [replay, criteria, quality, license, map, safety, blog];
for (var button in nav) {
    nav[button].initiateRollOvers2();
}
map.onRelease = map.onReleaseOutside=function () {
    if (_global.section != this._name) {
        _global.section = this._name;
        _parent.serviceHighlights.slideAndLoad('alaronMap.swf');
    }
};
  1. MovieClip.prototype.initiateRollOvers2 = function() {
  2.     this.onRollOver = function() {
  3.         this.gotoAndPlay("2");
  4.     };
  5.     this.onRollOut = this.onDragOut=function () {
  6.         this.gotoAndPlay("6");
  7.     };
  8. };
  9. var nav = [replay, criteria, quality, license, map, safety, blog];
  10. for (var button in nav) {
  11.     nav[button].initiateRollOvers2();
  12. }
  13. map.onRelease = map.onReleaseOutside=function () {
  14.     if (_global.section != this._name) {
  15.         _global.section = this._name;
  16.         _parent.serviceHighlights.slideAndLoad('alaronMap.swf');
  17.     }
  18. };
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Never mind. I just found confirmation from LiveDocs it can't be done.

http://livedocs.adobe.com/flash/9.0/mai ... 00011.html

Quote:
SWF files written in ActionScript 1.0 or 2.0 cannot load SWF files written in ActionScript 3.0. This means that SWF files authored in Flash 8 or Flex Builder 1.5 or earlier versions cannot load ActionScript 3.0 SWF files.

The only exception to this rule is that an ActionScript 2.0 SWF file can replace itself with an ActionScript 3.0 SWF file, as long as the ActionScript 2.0 SWF file hasn't previously loaded anything into any of its levels. An ActionScript 2.0 SWF file can do this through a call to loadMovieNum(), passing a value of 0 to the level parameter.
# In general, SWF files written in ActionScript 1.0 or 2.0 must be migrated if they are to work together with SWF files written in ActionScript 3.0. For example, say you created a media player using ActionScript 2.0. The media player loads various content that was also created using ActionScript 2.0. You cannot create new content in ActionScript 3.0 and load it in the media player. You must migrate the video player to ActionScript 3.0.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

If anyone is interested I worked around the problem. Fortunately the way my site is set up the workaround fits in just fine.

Instead of embedding it in the AS2 file, I just popped the AS3 file open in it's own window. If you want to see it go to the main page of the site and click the Map & Directions link.
http://www.alaron-nuclear.com/main.html

(you may need to allow popups from Alaron if you have a pop-up blocker)
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

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:

Quote:
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):
Code: [ Select ]
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"); }
 
};
  1. map.onRelease = map.onReleaseOutside=function () { 
  2.     import flash.external.ExternalInterface;
  3.     if (ExternalInterface.available) { ExternalInterface.call("window.open", "http://www.alaron-nuclear.com/alaronMap3-e.html", "win", "height=500,width=680,toolbar=no,scrollbars=yes"); }
  4.  
  5. };

"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:
Code: [ Select ]
<A href="javascript&#058; self.close ()">Close this Window</A>
 
  1. <A href="javascript&#058; self.close ()">Close this Window</A>
  2.  


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.

Code: [ Select ]
<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&#058; self.close ()">Close this Window</A>
</div>


</body>
</html>
  1. <html lang="en">
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  4. <title>Alaron Map and Directions</title>
  5. <script language="javascript"> AC_FL_RunContent = 0; </script>
  6. <script language="javascript"> DetectFlashVer = 0; </script>
  7. <script src="AC_RunActiveContent.js" language="javascript"></script>
  8. <script language="JavaScript" type="text/javascript">
  9. <!--
  10. // -----------------------------------------------------------------------------
  11. // Globals
  12. // Major version of Flash required
  13. var requiredMajorVersion = 9;
  14. // Minor version of Flash required
  15. var requiredMinorVersion = 0;
  16. // Revision of Flash required
  17. var requiredRevision = 45;
  18. // -----------------------------------------------------------------------------
  19. // -->
  20. </script>
  21. </head>
  22. <body bgcolor="#ffffff">
  23. <!--url's used in the movie-->
  24. <!--text used in the movie-->
  25. <script language="JavaScript" type="text/javascript">
  26. <!--
  27. if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
  28.     alert("This page requires AC_RunActiveContent.js.");
  29. } else {
  30.     var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
  31.     if(hasRightVersion) { // if we've detected an acceptable version
  32.         // embed the flash movie
  33.         AC_FL_RunContent(
  34.             'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0',
  35.             'width', '632',
  36.             'height', '400',
  37.             'src', 'alaronMap3-e',
  38.             'quality', 'high',
  39.             'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
  40.             'align', 'middle',
  41.             'play', 'true',
  42.             'loop', 'false',
  43.             'scale', 'showall',
  44.             'wmode', 'window',
  45.             'devicefont', 'false',
  46.             'id', 'alaronMap3-e',
  47.             'bgcolor', '#ffffff',
  48.             'name', 'alaronMap3-e',
  49.             'menu', 'true',
  50.             'allowScriptAccess','sameDomain',
  51.             'allowFullScreen','false',
  52.             'movie', 'alaronMap3-e',
  53.             'salign', ''
  54.             ); //end AC code
  55.     } else { // flash is too old or we can't detect the plugin
  56.         var alternateContent = 'Alternate HTML content should be placed here.'
  57.             + 'This content requires the Adobe Flash Player.'
  58.             + '<a href=http://www.macromedia.com/go/getflash/>Get Flash</a>';
  59.         document.write(alternateContent); // insert non-flash content
  60.     }
  61. }
  62. // -->
  63. </script>
  64. <noscript>
  65.     // Provide alternate content for browsers that do not support scripting
  66.     // or for those that have scripting disabled.
  67.     Alternate HTML content should be placed here. This content requires the Adobe Flash Player.
  68.     <a href="http://www.macromedia.com/go/getflash/">Get Flash</a>
  69. </noscript>
  70. <br />
  71. <div width="550" style="text-align:center;">
  72. <A href="javascript&#058; self.close ()">Close this Window</A>
  73. </div>
  74. </body>
  75. </html>
  • Jean-Paul Bardou
  • Newbie
  • Newbie
  • Jean-Paul Bardou
  • Posts: 8

Post 3+ Months Ago

Hi,

I have read this one-man thread with big interest, because I am having a terrible headache of the sort.

I wrote an application in cs3 using as2, and then, when the time came to implement a print function, I realized that it would have been a much better idea to do it in cs3.

Because I am a bit unsure that I can translate the whole thing into as3, I try to write the print function in as3 and "call it" from the other module.

You answered the question of feasibility: no go!

The next option, as you describe, to call the other page, is fine, weren't it for the fact that I need to pass parameters to the called module!

Do you have any idea of how I can do that?

In brief, the first module builds up a list of text fields chosen among a fixed set, and the print function must print the ones that were chosen.

I have written the guts of the print function now, and I need to be able to read the passed parameters.

I hope that you can answer this asap, of course...

Very truly yours,

Jean-Paul Bardou

P.S. It would be very nice to get notification by email that somebody has answered at jean.paul@e42.dk
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

I didn't look into this very closely at all but I think if you look into SWFBridge you'll figure out what you need. I remembered seeing it when I was troubleshooting my problem, but didn't need to pass parameters so I didn't study it.

http://pixelfumes.blogspot.com/2007/07/ ... s2-to.html
http://www.gskinner.com/blog/archives/2 ... easie.html

You may need to also look into localconnection
http://kb.adobe.com/selfservice/viewCon ... &sliceId=2

For future reference when you create a post in the right hand navigation column under Posting Information is a link that says Subscribe Topic. If you subscribe to this topic you'll get email notifications when there are new posts.
  • Jean-Paul Bardou
  • Newbie
  • Newbie
  • Jean-Paul Bardou
  • Posts: 8

Post 3+ Months Ago

Sorry for this empty message, I had forgotten to check the notify me button as you suggested...

Jean-Paul
  • Jean-Paul Bardou
  • Newbie
  • Newbie
  • Jean-Paul Bardou
  • Posts: 8

Post 3+ Months Ago

Hello again,

I am still unsure of how I can solve my as2 to as3 communcation problem.

It seems like actionscript bridge can be used when an as2 is included in an as3.

What about the case when there are two independent swfs, one in as2 that generates a set of values to be used by the other?

Anybody can help with code or pointers.

The task is simple:

swf 1, written in as2, generates a set of 11 integers, and depending on those, swf2, written in as3, must print various text info.

Of course, there might be another solution (if somebody can point to it): is it possible to write decent print code with as2, or are we back to stone-age #p and #bframe, etc, which is way insufficient for what I want.

For the time being, I have implemented a half-ass solution that sends the 11 integers to an aspx. The aspx then draws the propper html file to print.

I'd rather contain the whole process in flash.

I hope somebody will give me some pointers.

Very truly yours,

Jean-Paul
  • rajaa_sekaran
  • Born
  • Born
  • rajaa_sekaran
  • Posts: 2

Post 3+ Months Ago

Dear ATNO,

I have the same problem....Actually i have the as2 files with as2 video player..

But we are planed to upgrade our as2 video player in to as3...I created a as3 video player. Now the problem is i am not able to load separate as3 video player in to my as2 page....

It is possible work on that or we have to change all in as3...?
please Help me

Thanks in Advance

Rajasekaran P
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

You have to either change everything to AS3 or you have to work around it, like I did above
flash-forum/problem-loading-as3-swf-into-as2-swf-t90760.html#p520150
  • rajaa_sekaran
  • Born
  • Born
  • rajaa_sekaran
  • Posts: 2

Post 3+ Months Ago

Dear ANTO,

In my project i am using the player with in the flash file. So i cant call it in new HTML window.....

I heard its possible in flash player version 10.....I don't know its true or not.....

So .............. I will migrate the whole thing right.....?
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

I think that's all you can do, then is migrate the whole thing.
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

Well the deal is that you can only load an AS2 swf INTO an AS2 or AS3 parent. You CANNOT load an AS3 swf into an AS2 parent.

There were huge changes in the code base that are not backward compatible.
  • Jagu
  • Born
  • Born
  • Jagu
  • Posts: 1

Post 3+ Months Ago

Quote:
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.


This is a great workaround I created this cool googlemap using AS3 and now I cannot use it because all my main program files are in AS2. So I tried this published AS3 file and it does create an HTML page however the page does not show the embedded map because of security violation. So added the System.security.allowDomain("URL with the domain name"). I also allowed for IE 8 browser local setting to allow that domain name. Still I get Error message.

So even though the As3 file plays SWF file when I run Test movie from my CS4 professional fla file. Once published the HTML file displays security errors.

Post Information

  • Total Posts in this topic: 14 posts
  • Users browsing this forum: No registered users and 15 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.