Created
April 12, 2013 10:27
-
-
Save matthua/5371100 to your computer and use it in GitHub Desktop.
Externally hosting secondary swf files (iOS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import flash.display.Loader; | |
import flash.display.Sprite; | |
import flash.events.Event; | |
import flash.events.IOErrorEvent; | |
import flash.net.URLRequest; | |
import flash.system.ApplicationDomain; | |
import flash.system.LoaderContext; | |
public class SampleMainSwf extends Sprite | |
{ | |
private var externalLoader:Loader; | |
private var url:String= "http://www.xyz.com/Level1.swf"; | |
private var urlRequest:URLRequest = new URLRequest(url); | |
private var ldrContext:LoaderContext; | |
public function SampleMainSwf() | |
{ | |
externalLoader = new Loader(); | |
externalLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler); | |
externalLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,errorHandler); | |
ldrContext=new LoaderContext(false,ApplicationDomain.currentDomain,null); | |
try | |
{ | |
externalLoader.load(urlRequest, ldrContext); | |
} | |
catch(e:Error) | |
{ | |
trace("Error ID : "+e.errorID+"\nError Message : "+e.message); | |
} | |
} | |
private function completeHandler(e:Event):void | |
{ | |
addChild(externalLoader); | |
} | |
private function errorHandler(e:IOErrorEvent):void | |
{ | |
trace("In IO ErrorEvent Handler"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
During IPA packaging, ADT extracts the Actionscript code from all child SWFs which are specified within the sample text file, adds it to the final executable and moves the stripped SWFs into the "externalStrippedSwfs" folder created in the current working directory. The directory structure within the "externalStrippedSwfs" folder remains the same as specified within the text file. The generated stripped SWF's can be externally hosted on a web server.
A working sample Actionscript code which loads a secondary swf derived using the above workflow, from an external server is as follows.