Skip to main content
Participant
October 19, 2016
Question

Loding swfs into main app

  • October 19, 2016
  • 1 reply
  • 737 views

Hi all,

I've having a big problem with one of my apps.

'I have one main app that supposed to load a lot of external swfs(around 40-50) with code in all, I tried to add them in the package but Flash Animate hangs when I try to compile.(If I reduce it to around 10 it works). To get around this I made a zip with all the externals and made some functions for dowloading that zip an unpacking them to the application folder but then I get the "Uncompiled Actionscript"-error instead.

Please does someone know of a way to solve this without starting to migrate my swfs to a smaller amount of files?

Best regards

/magnus

This topic has been closed for replies.

1 reply

deesharm
Adobe Employee
Adobe Employee
October 20, 2016

Hi Magnus,

Could you please help us further with below queries:

1. Your application is designed for, which platform (iOS or Android)

2. It will be very helpful for us if you can provide a sample code snippet through which you are downloading the zip and unpacking them to the application folder.

If your application is iOS specific there are certain points that need to be addressed at the time of development for such application:

- Please specify exceptions to the default behavior by adding keys to InfoAdditions tag of application descriptor of your app.

- Please refer to below blogs on loading external swf for AIR apps on iOS:

https://blogs.adobe.com/airodynamics/2013/03/08/external-hosting-of-secondary-swfs-for-air-apps-on-ios/

Packaging and loading multiple SWFs in AIR apps on iOS

Thanks,

Adobe AIR Team

m_wallonAuthor
Participant
October 20, 2016

Hi and thanks for your time!

Zipp functionality works great, everything loads fine and I can read the "library"-xml inside without problem, it's when I load the first swf the problem from the unzipped folder i get this error "Uncompiled Actionscript"(some things are hardcoded here just to see that all linkages are working )

The code for zip functionality:

-- code  --

//// ---------------------------------------

//// -------------Download zip  --------------

//// ---------------------------------------

var _urlReq;

var _urlStream;

var _fileData;

var _file

var _writeFileStream

var zipName;

downLoadFile("http://bluwall.se/sfi/bostad.zip","bostad.zip")

function downLoadFile(_url,_name){

  zipName = _name;

  _urlReq = new URLRequest(_url);

  _urlStream = new URLStream();

  _urlStream.addEventListener(flash.events.ProgressEvent.PROGRESS, progressHandler, false, 0, true);

  _urlStream.addEventListener(Event.COMPLETE, saveFileToDisc);                      

  _urlStream.addEventListener(flash.events.IOErrorEvent.IO_ERROR, errorHandler, false, 0, true);

  _urlStream.load(_urlReq);

}

function progressHandler(e:ProgressEvent):void {

  trace("Downloadprogress: " + Math.round(100 * (e.bytesLoaded / e.bytesTotal)));

}

function errorHandler(evt:flash.events.IOErrorEvent):void {

  trace("Error: " + evt.text);

}

var fileData:ByteArray = new ByteArray();

var fileName:String;

var fileLocal:File;

function saveFileToDisc(event:Event):void 

    { 

  trace("SaveFileToDisk");

        _urlStream.readBytes (fileData, 0, _urlStream.bytesAvailable); 

        resolveFile(); 

    }

function resolveFile():void {

  trace("resolveFile_1");

  fileLocal = File.applicationStorageDirectory.resolvePath(zipName); 

  var fileStream:FileStream = new FileStream(); 

  fileStream.addEventListener(Event.CLOSE, fileSaved); 

  fileStream.openAsync(fileLocal, FileMode.WRITE); 

  fileStream.writeBytes(fileData, 0, fileData.length); 

  fileStream.close();

}

function outputProgressHandler(event:OutputProgressEvent):void{

    if (event.bytesPending == 0){

        trace("File is completely written");

    }

}

function filestreamErrorHandler(evt:flash.events.IOErrorEvent):void {

  trace("SaveError: " + evt.text);

}

function fileSaved(closeEvent:Event):void {

  trace("File saved");

  unZipFolder();

}

var _ex:ZipManager = new ZipManager();

_ex.addEventListener(ZipManagerEvent.START, onStart);

_ex.addEventListener(ZipManagerEvent.ERROR, onError);

_ex.addEventListener(ZipManagerEvent.PROGRESS, onProgress);

_ex.addEventListener(ZipManagerEvent.COMPLETED, onComplete);

     function onStart(e:ZipManagerEvent):void

     {

             trace("zip process started...");

     }

   

     function onError(e:ZipManagerEvent):void

     {

             trace("zip process ERROR: " + e.param.msg);

     }

    

     function onProgress(e:ZipManagerEvent):void

     {

             trace("zip Progress = " + e.param.perc + "%");

     }

    

     function onComplete(e:ZipManagerEvent):void

     {

             trace("zip process finished");

             unzippingDone();

     }

     function unZipFolder(){

         trace("try to unzip!!-->"+zipName)

          _ex.unzip(File.applicationStorageDirectory.resolvePath(zipName), File.applicationStorageDirectory.resolvePath("bostad"));

     }

     var directory;

     function unzippingDone(){

      

      directory = File.applicationStorageDirectory.resolvePath("bostad/bostad");

       var list:Array = directory.getDirectoryListing();

       trace("Number of files:"+list.length)

       for (var i:uint = 0; i < list.length; i++) {

            trace("-->File:"+list.nativePath);

       }

       getXml("bostad/bostad/parts.xml");

}

//----------------------------------------------------------

//  --- loading files from application folder, this function gets called everytime I like to open one of the downloaded swfs

//----------------------------------------------------------

     function startLoad(_u)

     {

            trace("---U----"+_u)

            var url2:File = File.applicationStorageDirectory.resolvePath("bostad/bostad/"+_u);

            var mRequest:URLRequest = new URLRequest(snd_url2.url);

            txt_title.text=_u;

            mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);

            mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);

            mLoader.contentLoaderInfo.addEventListener(Event.INIT, onInitHandler);

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

            mLoader.load(mRequest,lc);

     }

     function onCompleteHandler(loadEvent:Event)

     {

          var m = new MovieClip();

          m.addChild(loadEvent.currentTarget.content);

          kap_holder.addChild(m);

          loadedClip=m;

          kap_holder.visible=true;

          kap_holder.alpha=0;

          TweenLite.to(kap_holder, .3, {alpha:1});

          mc_loaderbar.visible=false;

     }

-- code end -------

I've looked att the examples you provided links for but don't really follow, as I understand I should add stripped version of all my swf to the package and the upload the zip with unstripped versions to my server and then excange the one in the package on runtime? If so the I still have the problem with to many files in the package and Flash won't compile.

Best regards and big thanks for the help!

/magnus

m_wallonAuthor
Participant
October 20, 2016

Hi again,

it's designed to work on both ios and android.

/magnus