Is it possible to embed or download SWF files when creating applications for iphone (is Apple allowed)

I got a little confused about whether to embed swfs or load them when creating iphone apps. Does anyone know what are the benefits of each (which is preferable to use)? I know that swfs attachment should be a little faster than loading them, but is that all?

This is also very important, I read that Apple will reject any application using external swfs? Is this really right? If so, would embedding or downloading the mentioned swfs solve this problem?

Thank you in advance

EDIT: after doing some searching around, it turns out that Apple has problems loading external swfs, you can still do it, but your swfs should not have an attached actioncript file, here is the link http://whizzkid74.blogspot.com/2010/ 12 / air-for-iphone-loading-external-swf.html However, it doesn’t say anything about embedding swfs, so my question is: is it possible to embed swfs when writing applications on iphone ??

EDIT To clarify when I say external SWF. I mean SWFs that are located on your system locally, but you need to add them to your program, because they contain MovieClips or Sprites, etc. that you need. I did not mean the SWFs that you need to download from a website or an online source. (hope this clarifies the situation)

EDIT Changed the name of the question ... The problem is solved, thanks for helping all the guys and happy new year = D

+4
source share
3 answers

Answer: yes, you can embed SWF, but this is not the only way. You can also use the usual Loader methods, with everything related to the main SWF:

var myLoader:Loader = new Loader(); // iOS apps act as if the main SWF is in a folder // and the other SWFs are in the same (or sub) folders. var url:URLRequest = new URLRequest("loadedSWF.swf"); myLoader.load(url); addChild(myLoader); myLoader.x = 50; myLoader.y = 30; 

With one caveat: during compilation (in the "Air for iOS" settings, in the "Included Files" list) you need to specify the SWF files that you want to download, and they will be compiled into IPA,

Thus, you cannot call external SWF files, but you can certainly access other SWF files using the embed tag or using (what you can call) an IPA attachment.


Edit:

Since the question and the name have changed a bit since I first answered this, here is a more general summary. Apple does not allow you to download local SWFs as if you were using Flash Player on a website. It is not possible to load SWF (or anything else) using "relative" or "local" links in the i-device if this content is not compiled into the application. This does not apply to some types of "remote" SWF downloads, nor does it apply to ActionScript encoding "Native", but this is not what the (original) question was about.

+2
source

Update, October 2012:

In Adobe AIR 3.5, adl introduces a feature called "multiple SWF support" that allows you to use Loaders to load SWF files delivered in .ipa (local files, not from servers) to have code in them. The ADL AOT compiler compiles SWFs that are included in .ipa, allowing them to boot and run on iOS.

AIR 3.5 is currently in beta testing at the time of this writing, available on adobe labs:

Note that this function requires -swf-version = 18 or more root SWF (not necessarily downloadable resources) and an AIR namespace ending in 3.5 in the xml application file.

Old answer:

I would like to update this answer because I learned a lot about this problem since I first studied it.

The root of the problem is that when creating iOS apps with AIR, Apple TOS prevents code from being interpreted at run time - and this includes SWF bytecode. Thus, loading SWFs with code in them (even simple animation commands, such as stop (), gotoAndPlay (), etc.), are Forbidden and will not work through Loader (before AIR 3.5).

  • Please note that to download vector image files to download SWF files is completely normal. A graphic is displayed, but the code will not be executed.

However, there are several workarounds for this. Both workarounds avoid Loader by compiling the assets with the code in them in the main SWF, because when they are part of the main SWF, the AIR (adt) compiler cross-compiles the code in objective-c and everything will work fine on iOS devices.

Using SWC Libraries

This is the best option for iOS development. If you compile your graphic objects (.fla file) into SWC (or export SWC from characters in your library), then compile your main swf against these SWCs, this will go through the compiler and ActionScript code that will run on iOS devices.

Using SWFMerge for [embed] ed SWF

Investing in SWF is very simple and looks like this:

 [Embed(source="GameLevel.swf")] private var GameLevel:Class; public function main():void { var my_level:* = new GameLevel(); addChild(my_level); } 

In this case, if there is code in gameLevel.swf, it usually does not work on iOS, because the new gameLevel () will create a Loader and interpret the SWF byte code. But if you first run the above SWF through my tool called SWFMerge, it will take your embedded SWF and merge it into your root SWF. Then ADT will compile your main swf (including embedded code) into objective-c, it will work on iOS, and note: now the new gameLevel () is now displayed directly in the instance of your asset - NOT a bootloader.

The SWFMerge tool is here:

http://www.onetacoshort.com/temp/SWFMerge_alpha.swf

Let me know in the comments if this workaround works for you or you are having problems.

Using Loaders

Prior to AIR 3.5, if you use Loader to download a SWF file (whether this swf is included in your IPA or served from a web server), the target SWF graphics will load just fine, but no code inside the SWF will execute , again, because it is forbidden by Apple TOS.

As in AIR 3.5, packing SWF files in .ipa as assets using Loader will work even if they contain code, as this code is now AOT-compiled adt. This requires -swf-version = 18 or more from the root SWF (not required for assets) and the AIR namespace ending in 3.5 in the xml application file.

However, it’s technically possible to interpret SWF bytecode, it’s just a ban on the use of the App Store. If you want to test only on the iOS device and will not distribute your application through the App Store, you can compile SWF using the adt -target ipa-test-interpreter parameter, and loading SWF with the code in them will work.

+7
source

I am not familiar with Apple and iPhone application rules, but as a rule, when I make applications / games, I implement everything. Benefits:

  • Your game / application is in one swf, making it easy to share
  • Your game / application loads faster since all assets are in boot mode
  • You do not depend on Internet access to get your assets (if you download them from the site) - useful for the application
  • Your game / application will "just work" - no security problems, no problems with changing URLs or changing a resource (if they are external)
  • If you use swc instead of swf (swc can also be loaded by btw), you can also use the strict type

Disadvantages:

  • If you need to upgrade one of your assets, you need to republish the game / application
+3
source

Source: https://habr.com/ru/post/1388729/


All Articles