2 Replies Latest reply on Sep 24, 2011 6:10 AM by Ned Murphy

    Repeative opening of external swf when only called once

    BubbaRichard

      I'm a newbie to flash (being in i.t. since 1989). I'm using the following method to load an external swf file. The method is called from the main movies constructors

       

        public function InitLoader(baseFile:String, skyFile:String = "") : void

        {

         if(skyFile.length > 0)

         {

          skyLoader.load( new URLRequest( skyFile ) );

          addChild( skyLoader );

         }

         imLoader.load( new URLRequest(baseFile) );

         imLoader.addEventListener(Event.COMPLETE, imLoader_complete);

         addChild( imLoader );

        }

       

      But the debug output shows these files are being loaded over and over again until the program crashes. What do I do? What did I do wrong?

       

      Thanks,

      Bubba

        • 1. Re: Repeative opening of external swf when only called once
          McbainGames11 Level 2

          Hey,

           

          Well you have completely wrong code.

          That uncompleted code you have attempted is for loading swf like a 'preloader'.

           

           

          To import outside .as files you use:


           

          import folder1.folder2.filename.as;

           

          ^^ I think that is what you are after but i added all the possibilities in also just incase!

           

           

           

          If you are using a .as class file use this to import:

           

          var myobject:classname = new classname();

           

          Hope it helped

          • 2. Re: Repeative opening of external swf when only called once
            Ned Murphy Adobe Community Professional & MVP

            Unless you have provided some other information to McbainGames11 that no one else is privy to, I would ignore that response as what you have shown has no resemblance to what is discussed.

             

            It is true that the function should only load once, but it is more likely a problem of that function being called more than once.  So try looking at wherever that function gets called and trace to see if it is being called mutliple times.

            1 person found this helpful