Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 154053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:54:38+00:00 2026-05-11T09:54:38+00:00

I’m currently experimenting with loading external SWF files from both an standard AS3 application,

  • 0

I’m currently experimenting with loading external SWF files from both an standard AS3 application, and an AIR application. It seems that the AIR application doesn’t act the same way a standard SWF run by the Flash Player does.

According to the documentation, the applicationDomain property of LoaderContext is usable in an AIR application too, but it just seems to be not working.

I have the following code :

package {     import flash.display.Loader;     import flash.display.LoaderInfo;     import flash.display.Sprite;     import flash.events.Event;     import flash.net.URLRequest;     import flash.system.ApplicationDomain;     import flash.system.LoaderContext;      public class Invoker extends Sprite     {         private var _ldr : Loader;          public function Invoker()         {             _ldr = new Loader();             _ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onChildOneComplete);              var ldrC : LoaderContext = new LoaderContext(false,                 new ApplicationDomain(ApplicationDomain.currentDomain)             );              _ldr.load(new URLRequest('otherSwf.swf'), ldrC);         }          private function onChildOneComplete(e : Event) : void         {             var c1ad : ApplicationDomain = (e.target as LoaderInfo).applicationDomain;             var inad : ApplicationDomain = ApplicationDomain.currentDomain;              trace('Child One parentDomain : ' + c1ad.parentDomain);             trace('Invoker parentDomain   : ' + inad.parentDomain);              trace('Child One has Invoker  : ' + c1ad.hasDefinition('Invoker'));             trace('Invoker has Invoker    : ' + inad.hasDefinition('Invoker'));         }     } } 

Compiling this code as an SWF file and launching it with the Flash Player does this output, which seems right :

Child One parentDomain : [object ApplicationDomain] Invoker parentDomain   : null Child One has Invoker  : true Invoker has Invoker    : true 

But the same code as an AIR application does a different output :

Child One parentDomain : null Invoker parentDomain   : null Child One has Invoker  : false Invoker has Invoker    : true 

According to the documentation, the first output (using a SWF with Flash Player, and not an AIR application) is the right one. Also, playing around with this snippet and changing the application domain to others possible configurations (like new ApplicationDomain(null), or ApplicationDomain.currentDomain) does exaclty what the documentation says with the SWF, but does not change the output of the AIR application.

Any clue why AIR is simply ignoring the application domain passed to the loader context ? Any documentation about this particular issue ?

Thank you very much.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:54:39+00:00Added an answer on May 11, 2026 at 9:54 am

    Got it.

    The issue was caused by a different behaviour in the SecurityDomain system within an AIR application. When a SWF file is loaded within an AIR application, it always depend to a different sandbox. Thus, AIR creates a new SecurityDomain for this SWF.

    Since a SecurityDomain is a group of one or more ApplicationDomains, this behaviour forced the creation of a new ApplicationDomain (within the new SecurityDomain), ignoring the specified one (which belong to the ‘main’ SecurityDomain).

    There is a workaround using URLLoader. When loaded from bytecode (using Loader.loadBytes), a SWF is loaded within the same SecurityDomain. This is why you have to put the allowLoadBytesCodeExecution to true, since it can be unsafe. So loading the SWF indirectly, first though an URLLoader, and then with Loader.loadBytes, solve this issue.

    Here’s the snippet :

    package {     import flash.display.Loader;     import flash.display.LoaderInfo;     import flash.display.Sprite;     import flash.events.Event;     import flash.net.URLLoader;     import flash.net.URLLoaderDataFormat;     import flash.net.URLRequest;     import flash.system.ApplicationDomain;     import flash.system.LoaderContext;     import flash.utils.ByteArray;      public class Invoker extends Sprite     {         public function Invoker()         {             var uldr : URLLoader = new URLLoader();             uldr.dataFormat = URLLoaderDataFormat.BINARY;             uldr.addEventListener(Event.COMPLETE, onBytesComplete);              uldr.load(new URLRequest('otherSwf.swf'));         }          private function onBytesComplete(e : Event) : void         {             var bytes : ByteArray = (e.target as URLLoader).data;              var ldr : Loader = new Loader();             ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onChildComplete);              var ldrC : LoaderContext = new LoaderContext();              // This property was for AIR 1.0.             //ldrC.allowLoadBytesCodeExecution = true;              // Since AIR 2.0, it's allowCodeImport.             ldrC.allowCodeImport = true;              ldr.loadBytes(bytes, ldrC);         }          private function onChildComplete(e : Event) : void         {             var c1ad : ApplicationDomain = (e.target as LoaderInfo).applicationDomain;             var inad : ApplicationDomain = ApplicationDomain.currentDomain;              trace('Child One parentDomain : ' + c1ad.parentDomain);             trace('Invoker parentDomain   : ' + inad.parentDomain);              trace('Child One has Invoker  : ' + c1ad.hasDefinition('Invoker'));             trace('Invoker has Invoker    : ' + inad.hasDefinition('Invoker'));         }     } } 

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a JSP page retrieving data and when single or double quotes are
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.