• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Air for IOS Including files in IPA (SWF)

New Here ,
Jun 08, 2011 Jun 08, 2011

Copy link to clipboard

Copied

I've added a SWF file to the included files list in Publish Settings that I would like to load.

Any ideas on how to get it to work?

Here is my code:

import flash.net.URLRequest;

import flash.display.Loader;

import flash.events.Event;

import flash.events.ProgressEvent;

import flash.filesystem.File;

function startLoad()

{

var file:File = File.applicationDirectory.resolvePath("SomeFile.swf");

var mLoader:Loader = new Loader();

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

var context:LoaderContext = new LoaderContext();

context.checkPolicyFile = true;

context.securityDomain = SecurityDomain.currentDomain;

context.applicationDomain = ApplicationDomain.currentDomain;

mLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);

mLoader.contentLoaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleGlobalErrors);

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

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

try {

     mLoader.load(mRequest, context);

} catch (error:Error) {

     mLoader.load(mRequest);

}

}

function handleGlobalErrors( evt : UncaughtErrorEvent ):void

{

     evt.preventDefault();

}

function onCompleteHandler(loadEvent:Event)

{

     addChild(loadEvent.currentTarget.content);

}

function onProgressHandler(mProgress:ProgressEvent)

{

     var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;

     trace(percent);

}

function ioError(event:ErrorEvent):void {

}

startLoad();

TOPICS
Development

Views

27.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 08, 2011 Jun 08, 2011

Copy link to clipboard

Copied

Whats the issue you are facing? Are you not able to generate the ipa for your project? Or you are not able to execute/run ipa on your device?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 08, 2011 Jun 08, 2011

Copy link to clipboard

Copied

Everything works with the IPA. I'm able to generate it just fine. It loads perfect on my iPad, but I'm having trouble accessing the local SWF that I attached to the IPA publish settings.

How can I access files that I've included via the Publish Settings (Included Files) list?

I basically want to load an .swf file into my ipad app from the local directory on the ipad. Am I accessing the local directory correctly in my code above?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 08, 2011 Jun 08, 2011

Copy link to clipboard

Copied

You don't want to be using file references, just use Loader and URLRequest like you would for web access.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 08, 2011 Jun 08, 2011

Copy link to clipboard

Copied

I originally tried using a URLRequest but I don't think it will work because of security limitations. Thats why I wanted to go the route of including my external .swf file in the actual IPA itself.

Is it possible to load a external web based SWF file into a Air App for IOS?

var mRequest:URLRequest = new URLRequest("http://domain.com/someFile.swf");

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 08, 2011 Jun 08, 2011

Copy link to clipboard

Copied

You can load swfs either locally or from the web, using urlrequest, but in no case can you load a swf that has actionscript in it. That's not allowed.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 08, 2011 Jun 08, 2011

Copy link to clipboard

Copied

Thanks for the heads up. Yes the SWF file in question contains actionscript. So I guess it wont work.

This brings me to my next question.

What is the best method of converting a SWF into an IPA file?

I sucessfully converted it to an .AIR app by doing the following:

adt -package -storetype pkcs12 -keystore test.p12 -tsa none someApp.air someApp.xml someApp.swf -C icons

it worked fine... then I tried converting to an IPA by running:

adt -package -target ipa-debug -keystore iphone_dev.p12 -storetype pkcs12 -keystore -provisioning-profile MY.mobileprovision someApp.ipa someApp.xml someApp.swf icons Default.png

and I just get some wierd errors:

at adobe.abc.GlobalOptimizer.prop_null(GlobalOptimizer.java:4653) at adobe.abc.GlobalOptimizer.prop_null(GlobalOptimizer.java:4653) at adobe.abc.GlobalOptimizer.prop_null(GlobalOptimizer.java:4653) at adobe.abc.GlobalOptimizer.prop_null(GlobalOptimizer.java:4653)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jun 08, 2011 Jun 08, 2011

Copy link to clipboard

Copied

Yes, external swf with script won't work, but I have successfully loaded  many swf by controlling everything from my index file. Did you  downloaded the Latest AIR SDK and AIR 2.6 which supports both ios and  android? What version of flash IDE?

Sample format:

instead of debug use ipa-test and make sure you have all the files within your package

C:\AdobeAIRSDK\bin\adt.bat -package -target ipa-test -storetype pkcs12 -keystore [KEYFILE].p12 -storepass [KEY PASSWORD] -provisioning-profile [MOBILE PROVISION FILE].mobileprovision [IPA NAME].ipa [XML FILE NAME].xml [SWF FILE NAME].swf Icon_29.png Icon_48.png Icon_57.png Icon_72.png Icon_512.png Default-Landscape.png Default-Portrait.png Default-PortraitUpsideDown.png Default-PortraitLandscapeLeft.png Default-PortraitLandscapeRight.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 09, 2011 Jun 09, 2011

Copy link to clipboard

Copied

Can you post an example of your XML file?

I have the latest AIR runtime.

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 09, 2011 Jun 09, 2011

Copy link to clipboard

Copied

I just tried again with a different swf file and I was able to succesfully convert it to an IPA.

Are there some SWF's that are unable to be converted?

FYI In case anyone is interested I'm trying to convert an Xcelsius .swf dashboard to ipa. I was able to convert it to an .air format just fine, but not .ipa. I keep getting errors:

at adobe.abc.GlobalOptimizer.prop_null(GlobalOptimizer.java:4653) at adobe.abc.GlobalOptimizer.prop_null(GlobalOptimizer.java:4653) at adobe.abc.GlobalOptimizer.prop_null(GlobalOptimizer.java:4653) at adobe.abc.GlobalOptimizer.prop_null(GlobalOptimizer.java:4653)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jun 09, 2011 Jun 09, 2011

Copy link to clipboard

Copied

Hi,

This looks like a bug in adt. Does this happen for any Xcelsius swf file. Could you send me one at mailto:sanika@adobe.com so that I can try it at my end?

Thanks,

Sanika

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 10, 2011 Jun 10, 2011

Copy link to clipboard

Copied

It appears to only be happing on certain Xcelsius swf files I try. I was able to get it working on a very simple Xcelsisus file I tried. As when it produces the error it doesn't appear to be writing a log file. Is there any way to force a log file/stack trace to be written via command line? Thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 19, 2011 Aug 19, 2011

Copy link to clipboard

Copied

Hi,

Iam getting the similar error and did anybody has solution for this error

  at adobe.abc.GlobalOptimizer.prop_null(GlobalOptimizer.java:4653)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 21, 2011 Aug 21, 2011

Copy link to clipboard

Copied

Hi,

This looks like a bug.

Can you please send me your swf and app xml to mohd@adobe.com so that i could try it at my end.

Thanks,

Amish.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 21, 2011 Aug 21, 2011

Copy link to clipboard

Copied

Hi Deepak,

I got the swf and app xml that you sent to Sanika.

Thanks for reporting the issue. We are working on it.

If possible, please mail me the source code of the swf which caused the problem to you. It will help us in analysing the issue.

Thanks,

Amish.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 22, 2011 Aug 22, 2011

Copy link to clipboard

Copied

Amish,

The swf file is the output of the xcelsius file and there is not split

source codile or as3 script for this.if you want the xlf file ican send it

to you but they are just the graph component images.

Regards

Deepak

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 23, 2011 Aug 23, 2011

Copy link to clipboard

Copied

Hi Deepak,

We are working on it. You can send the xlf file to mohd@adobe.com.

Thanks,

Amish.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 08, 2011 Jun 08, 2011

Copy link to clipboard

Copied

For instance if I try to load the SWF from a URL I get the following security error in Flash CS 5.5:

*** Security Sandbox Violation ***

SecurityDomain 'http://www.domain.com/someFile.swf' tried to access incompatible context 'app:/someApp.swf'

If I export the project as a SWF file in Flash and double click on the .swf windows gives me a dialog box:

"Adobe Flash Player has stopped a potentially unsafe operation. The following local application on your computer or network is trying to communicate with this Internet-enabled location: www.domain.com"

When I click "OK" it loads the SWF in Flash Player and then loads the external SWF perfectly.

import flash.net.URLRequest; import flash.display.Loader; import flash.events.Event; import flash.events.ProgressEvent; function startLoad() { var mLoader:Loader = new Loader(); var mRequest:URLRequest = new URLRequest("http://www.domain.com/someFile.swf"); var context:LoaderContext = new LoaderContext(); context.checkPolicyFile = true; context.securityDomain = SecurityDomain.currentDomain; context.applicationDomain = ApplicationDomain.currentDomain; mLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError); mLoader.contentLoaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleGlobalErrors); mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler); mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler); try {      mLoader.load(mRequest, context); } catch (error:Error) {      mLoader.load(mRequest); } } function handleGlobalErrors( evt : UncaughtErrorEvent ):void {      evt.preventDefault(); } function onCompleteHandler(loadEvent:Event) {      addChild(loadEvent.currentTarget.content); } function onProgressHandler(mProgress:ProgressEvent) {      var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;      trace(percent); } function ioError(event:ErrorEvent):void { } startLoad();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 15, 2011 Jun 15, 2011

Copy link to clipboard

Copied

I'm testing an iPad app at the moment and I can confirm, that you can:

  1. include external SWFs in an IPA package
  2. load the SWFs with a Loader and URLRequest using a relative path

The external SWFs, however, cannot include any actionscript (even stop() actions). When the SWFs contained actionscript: their audio would play in the background, the COMPLETE would not fire, and there was no indication of an IOError or any other failure.

I spent a while trying to figure this out before finding this thread, so I wanted to spell it out plainly for anyone else in this situation.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 25, 2011 Jul 25, 2011

Copy link to clipboard

Copied

When you say that "external SWFs cannot contain actionscript", does that include SWFs that were built into the .ipa by going to the "File->Air for iOS Settings..." and including SWFs via the "Included files" part of the "General" tab?

I have a project with 50+ SWFs in it (all that I have the .FLA files for) and all have actionscript in them.  I am looking for a painless way to convert it to Air for iOS.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 25, 2011 Jul 25, 2011

Copy link to clipboard

Copied

It does apply to the "included files." The easiest way to include them is to put them all in a single folder and include the folder within the iOS Publish Settings.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 25, 2011 Jul 25, 2011

Copy link to clipboard

Copied

I did put them all in a folder and include the folder in the iOS publish settings, but since all of the 50+ SWFs contain actionscript, if I am reading your response correctly, it looks like I will need another solution for iOS.

By the way, it does work fine under Android, just not under iOS.

Do you know if there is a way to include a bunch of .FLAs into one "Air for iOS" app?  In other words, when I publish, CS5.5 will just compile each of the FLAs into one Air for iOS app?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 25, 2011 Jul 25, 2011

Copy link to clipboard

Copied

I would use JSFL to either:

  1. Remove the AS from every file -OR-
  2. Make each SWF timeline into a symbol and include them in the main FLA (so there is only 1 file)

You could look into use a runtime library, either SWF or FLA, but both options would likely require you to bring every timeline into 1 library file.

Additionally, you might also be able to include something like the following code in each SWF that will allow you to load them in:

Security.allowDomain(this.loaderInfo.loaderURL);

or

Security.allowDomain("*");

reference: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Security.html#allowDomain%28%29

I haven't tried it, but it may work.

Also check out:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/LoaderInfo.html

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 25, 2011 Aug 25, 2011

Copy link to clipboard

Copied

I have a similar issue.  I'm loading an swf thats included in the ipa that has symbols exported for actionscript but no other code.  The strange thing is that if I do a debug build it works fine on the iphone and ipad.  However when I try to do a release build I get

Exception in thread "main" java.lang.Error: Unable to find named traits:

public::Name of art asset

at adobe.abc.Domain.resolveTypeName(Domain.java:225)

at adobe.abc.Domain.resolveTypeName(Domain.java.142)

at adobe.abc.GlobalOptimizer$InputAbc.resolveTypeName(GlobalOptimizer.java:272)

at adobe.abc.GlobalOptimizer$InputAbc.resolveSlotType(GlobalOptimizer.java:947)

at adobe.abc.GlobalOptimizer$InputAbc.resolveType(GlobalOptimizer.java:535)

at adobe.abc.GlobalOptimizer$InputAbc.resolveTypes(GlobalOptimizer.java:448)

at adobe.abc.LLVMEmitter.generateBitcode(LLVMEmitter.java:239)

at com.adobe.air.ipa.AOTCompiler.convertAbcToLlvmBitcodeImpl(AOTCompiler.java.446)

at com.adobe.air.ipa.BitcodeGenerator.main(BitcodeGeneratore.java:81)

Compilation failed while executing : ADT

I've googled around for this and it sounds like I shouldn't be able to load the swf externally even if included in the IPA but it's strange that it works for the debug IPA...

Any information on this would be appreciated.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 25, 2011 Aug 25, 2011

Copy link to clipboard

Copied

As per adobe the compiler fails because stack overflow issue in the action script.currently they said

"You can package your application in interpreter mode. (“Packaging method: Fast (packaging takes several seconds, application runs slower than release build option in Flash Builder)."

Iam assuming they recommend the debug mode(requested them to confirm but did not get any update yet,if i hear something then will post here)The other solution is to run on a machine with higher RAM of your current machine and test.The last option is they got the solution now but do have to wait until there next release,which is coming soon.

Let me know if you got it working on higher RAM machine,I will also try and post the updates.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines