Skip to content

Instantly share code, notes, and snippets.

@sportebois
Created October 14, 2013 00:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sportebois/6969008 to your computer and use it in GitHub Desktop.
Save sportebois/6969008 to your computer and use it in GitHub Desktop.
Loader override to workaround the swf loading issues on iOS when migrating from Air 3.5 to Air 3.9 (to be iOS7 compliant)
package com.yourdomain.utils.loader
{
import flash.display.Loader;
import flash.filesystem.File;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
import flash.utils.getTimer;
/**
* Extension of the classic flash.display.Loader that automatically define
* the Application Domain (if not set) when starting a load, to make sure
* to comply with Air 3.6+ requirements
*
*/
public class ApplicationDomainLoader extends Loader
{
public function ApplicationDomainLoader()
{
super();
}
override public function load(request:URLRequest, context:LoaderContext=null):void
{
context ||= new LoaderContext(false, ApplicationDomain.currentDomain, null);
var url:String = request.url;
if (url.indexOf(":/") == -1)
{
var dir:File = File.applicationDirectory;
if (url.indexOf(".swf") == -1)
{
dir = dir.resolvePath(url);
request.url = dir.url;
} else {
// Generate a brand new file path to make sure the file is considered as a new swf
// This enables to workround the Air 3.6 issue on iOS where we cannot reload a swf that has been unloaded
// (@see Error #3764: Reloading a SWF is not supported on this operating system.
dir = dir.resolvePath(url);
request.url = dir.url + "?newfile="+getTimer();
request.cacheResponse = false;
request.useCache = false;
}
}
super.load(request, context);
}
}
}
@xerx
Copy link

xerx commented Dec 9, 2013

This works fine for me when ios deployment type is "Device testing" or "Device debugging" but when it is "Ad hoc" or "Apple App Store" then the app freezes and there is no reloading at all.

My settings are:

  • Flash CC
  • Adobe Air 3.9

If you have a solution on this then I would be really grateful.

@iamDavidLai
Copy link

My iOS deployment type is "Ad Hoc" & "App Store" ,
Provisioning Profiles contain 2 types: "Ad Hoc" & "App Store", then I tried to cross comparison on iPad 3.
It works fine and haven't any freezes.

My testing environment :
IDE - Flash CC 2014
SDK - AIR 21.0.0.176 for iOS

@ xerx, maybe these setting are helpful to you. Good luck :)
@ Sébastien Portebois, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment