1 Reply Latest reply on Feb 10, 2010 10:31 PM by galtzur

    Loaded Custom SWF not stopping at stop()

    galtzur

      Hello all. I hope you can help me, since i can't find the answer for a couple of days now.

      I have created a SWF file using a class I created as the main class for the swf. this swf is a movieclip with a frame labeld "open" and a stop action at the last frame

      the main class of the SWF:

      /*************************************/

      /********* PageSwf class *********/

      package {

       

          import flash.display.MovieClip;

       

          public class PageSwf extends MovieClip {

       

              public function PageSwf() {
                  stop();
              }

       

              public function open():void {
                  gotoAndPlay("open")
              }

       

          }
      }

      /*************************************/

       

      I load this SWF in another fla using a Loader object, and once it is loaded i run the open function i created:

      /*****************************************************/

      /********* SwfLoaderclass - main class*********/

      package {

       

          import flash.display.Sprite;

       

          public function SwfLoader() {

              var loader:Loader

              loader.contentLoaderInfo.addEventListener(Event.INIT, handleInit);
              try {
                  loader.load(new URLRequest("file.swf")); // file.swf is the PageSwf I am loading
              } catch (e) {
                  trace("error was catched loading file");
              }

       

              private function handleInit(ev:Event):void {
                  var loaderInfo:LoaderInfo = LoaderInfo(ev.target)
                  PageSwf(loaderInfo.content).open()
              }

       

          }
      }

      /*************************************/

       

      the problem is when I run the open function, after loading the swf it doesn't stop at the last frame. in fact it does not stop in any of theframes that have stop action in them.

      So far what i figured out is that if don't convert the content to PageSwf, and put it in a genereal variable and the run the open function it works
      just fine.
      the example of the code that works is:

       

      /*************************************/

      private function handleInit(ev:Event):void {
            var loaderInfo:LoaderInfo = LoaderInfo(ev.target)
            var loadedFile:* = loaderInfo.content

           loadedFile.open()
      }

      /*************************************/