1 Reply Latest reply: Feb 3, 2010 5:21 AM by Ned Murphy RSS

    Strange behaviour of .swf movies - AS2/AS3

    marcoolivotto Community Member

      Hello from Italy,

           this is my first post and I think I need some help from the experts...

           I am putting together an interactive Flash movie which is made of several different small movies. For the sake of clarity, I'll call them A.swf, B.swf, ..., Z.swf. The movies are launched from each other depending on certain buttons I've implemented.

           The first one, A.swf, is actually a sort of "main menu": it grants access to all the other movies and it is also the point of return from them when a certain button is pressed.

           Important: All the movies are scripted in AS3, except for the last one which, for a number of reasons, is scripted in AS2.

           The return from any (but the last) movie to the first, say B.swf to A.swf, is implemented like this:

       

      function eventResponseSole(event:MouseEvent):void {

      var myLoader:Loader = new Loader();

      addChild(myLoader);

      var url:URLRequest = new URLRequest("A.swf");

      myLoader.load(url);

      }

      sole_btn.addEventListener(MouseEvent.CLICK, eventResponseSole);

       

           This is, of course, AS3.

           The last movie, which is scripted in AS2, returns to A.swf like this:

       

      luna_btn.onRelease = function() {

      loadMovie("A.swf", _root);

      }

           The strange behaviour is this: if I launch Z.swf and navigate with the proper button up to A.swf, everything works. But if I launch A.swf, navigate to Z.swf and attempt to return, this doesn't work. There are no problems, instead, moving up and down between movies scripted in AS3, that is with the first bit of code I've pasted. My guess is that the syntax in AS2 is correct, but something stops A.swf from "launching itself" when the control is transferred to Z.swf, but the movie is launched in the original window. Is this diagnosis reasonable? And if so, would someone kindly provide a way out of this? Re-doing Z.swf in AS3 is not an option, I'm afraid, it will have to stay as it is. I also have to add I've tried some solutions by setting _lockroot, but this doesn't seem to work.
           Many thanks in advance!
           Marco Olivotto

        • 1. Re: Strange behaviour of .swf movies - AS2/AS3
          Ned Murphy CommunityMVP

          Mixing AS2 into AS3 is not without stipulations... and I am no expert on translating those stipulations, but here is what the Flash documentation says regarding the matter... the third paragraph may be significant to your case:

           

        • - ActionScript 3.0 code can load a SWF file written in ActionScript 1.0 or 2.0, but it cannot access the SWF file's variables and functions.
        •  
        • - 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.