3 Replies Latest reply: Mar 6, 2013 9:13 AM by kglad RSS

    External SWF Looping in IOS

    Vendita3 Community Member

      My main SWF has buttons that load other SWF files.

      When I preview this with Flash it works as I would expect. The external SWF runs a simple movie and the last frame of the movie I have added stop(); so it will not loop.

      This works fine in my browser and with Flash Preview. It even works fine with XCode when I preview it on their IOS Simulator.

       

      When I load this on my IPhone the movies will load correctly, but will loop continusly.

       

      Any ideas how I can stop the looping?

        • 1. Re: External SWF Looping in IOS
          kglad CommunityMVP

          iOS won't allow any code in your loaded swf to execute.

           

          so, one solution is to execute the stop from the loading (main) swf:

           

          var loader:Loader=new Loader();

          loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeF);

          loader.load(new URLRequest("yourexternalswf.swf"));

          function completeF(e:Event):void{

          MovieClip(loader.content).addEventListener(Event.ENTER_FRAME,enterframeF);

          }

          function enterframeF(e:Event):void{

          if(MovieClip(loader.content).currentFrame==MovieClip(loader.content).totalFrames){

          MovieClip(loader.content).removeEventListener(Event.ENTER_FRAME,enterframeF);

          MovieClip(loader.content).stop();

          }

          }

          • 2. Re: External SWF Looping in IOS
            Vendita3 Community Member

            Hi - Many thanks for this. I will try this now.

             

            Can you please let me know if you have a min this page (seems new) on Adobe and says you can load in action scripts:

             

            http://blogs.adobe.com/airodynamics/2012/11/09/packaging-and-loading-multiple-swfs-in-air- apps-on-ios/

             

            I am stuck with the bit saying *The minor change is that when loading the SWF, the application domain should be the same as that of the main SWF i.e. ApplicationDomain.currentDomain.

             

            var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);

            _loader.load(_urlRequest, _lc);

             

            Do I need to change "ApplicationDomain.currentDomain" (and what with)? or will this still not do what I am trying to do?

            • 3. Re: External SWF Looping in IOS
              kglad CommunityMVP

              no, leave that code just the way it is.

               

              if you're using an air version that allows code in external swfs, you should be good to go.

               

              unfortunately, i don't see which air versions allow external swf code.