Paratrooper Digital

Working with plugins and OSMF locally

Recently we’ve been taking a look at the OSMF.

While looking into plugins and plugin loading, we found a “feature” of loading plugins locally. It wont work if you use relative pathing.

By default you just get a LoadEvent that is pretty non descriptive. Turn on logging with the compiler directive (-define CONFIG::LOGGING true) and you’ll get some output that eludes to local files loafing into the same security context as the loading file.

Fri Apr 15 2011 02:56:01 PM [DEBUG] [org.osmf.elements.loaderClasses.LoaderUtils] Loading SWF into current security domain: GTrackPlugin.swf
Fri Apr 15 2011 02:56:01 PM [DEBUG] [org.osmf.elements.loaderClasses.LoaderUtils] Loading SWF into separate application domain: GTrackPlugin.swf

If you dig deep enough into the LoaderUtils class you’ll find that a SecurityError gets triggered.

Error #2142: Security sandbox violation: local SWF files cannot use the LoaderContext.securityDomain property.

The load system that OSMF uses for loading plugins has a specific chunk of code in it that looks for the presence of file:// at the beginning of the path of what file to load. If you have a path thats relative or root relative it should load locally, but it doesn’t.

// Local files should never be loaded into the current security domain.
if (	useCurrentSecurityDomain &&^file:\//i) == -1 )
	context.securityDomain = SecurityDomain.currentDomain;

This looks to be used in SWFLoader and ImageLoader and defaults to false, so it shouldn’t be an issue, but it was.

This is due to the DynamicPluginLoader

// We'll use a SWFLoader to do the loading.  Make sure we load the
// SWF into the same security domain so that the class types are
// merged.
var swfLoader:SWFLoader = new SWFLoader(true);

The quick solutions:

  • is to make your path to the plugin that you are attempting to load be an absolute path starting with file://
  • do all your testing on files pulled from a web server.
  • Dont use the DynamicPluginLoader
Comments are locked for this content.

About Nate Frank

Nate is currently a Senior Presentation Layer Architect at Razorfish Chicago. As an SPLA Nate: participates in technology leadership team and resource allocations, manage fulltime and contractor resources, represents technology for groups of brands across multiple clients, furthers development of standards within the office, architects project implementations and fosters community and mentoring.

View all posts by Nate Frank

Most recent posts