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

  • Home
  • SEARCH
  • 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 1020283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:08:40+00:00 2026-05-16T11:08:40+00:00

I’m having something of an issue with trying to load externally defined classes in

  • 0

I’m having something of an issue with trying to load externally defined classes in actionscript 3.0. I believe this to be an issue with my understanding of the ApplicationDomain / LoaderContext classes, but even after going over the documentation and a couple of web searches I’m still stuck.

Essentially what I want to do is load a swf that contains a symbol that is an implementation of an interface shared between the calling swf and the loaded swf. I can load the swf fine and instantiate and execute methods on it fine, but only so long as I don’t attempt to cast it to the shared interface type. If I do attempt to cast it, I get a TypeError: Error #1034: Type Coercion failed: type error.

I suspected this is because when I load the new class flash is recognizing it as a completely different class, hence the exception. The documentation suggests the use of a LoaderContext argument, with applicationDomain set to ApplicationDomain.currentDomain.

The problem is this has no effect. Regardless of whether I set the ApplicationDomain to currentDomain, null, or a child of the current domain, I still get an type coercion failed error. The :: part of the error seems to indicate that the class I loaded is in a different namespace or some such, when I want it to be in the same namespace as my loader.

Code:

import flash.display.Loader;
import flash.display.MovieClip;
import flash.events.Event;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;

public class TestSkin extends MovieClip
{
    var mLoader:Loader;

    public function TestSkin()
    {
        super();
        startLoad("ExternalTest.swf");
    }

    private function startLoad(url:String):void
    {
        mLoader = new Loader();
        var mRequest:URLRequest = new URLRequest(url);
        var appDomain:ApplicationDomain = ApplicationDomain.currentDomain;
                    //Loading into different domains seems to have no effect
        //var appDomain:ApplicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
        //var appDomain:ApplicationDomain = null;
        mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
        mLoader.load(mRequest, new LoaderContext(false, appDomain));
    }

    private function onCompleteHandler(loadEvent:Event):void
    {
        //Get the object from the loadEvent
        var obj:Object = loadEvent.target.content;
        //Verify that the methods exist on the object
        trace("Loaded item id: " + obj.getInterfaceId());
                    //This returns Loaded item id: ExternalTestInterfaceImplementation!
        //Try assigning as an instance of the shared type - fails with type coercion error
                    //Throws the following type error:
                    //TypeError: Error #1034: Type Coercion failed: cannot convert myPackage::ExternalTestInterfaceImplementation@257b56a1 to myPackage.TestInterface.
        var castItem:TestInterface = TestInterface(obj);
        trace("castItem: " + castItem);
    }
}

Interface declaration:

public interface TestInterface 
{
    function getInterfaceId():String;
}

Interface implementation

public class ExternalTestInterfaceImplementation extends MovieClip implements TestInterface 
{
    public function getInterfaceId() : String
    {
        return "ExternalTestInterfaceImplementation!";
    }

    public override function toString():String
    {
        return getInterfaceId();    
    }
}
  • 1 1 Answer
  • 0 Views
  • 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. Editorial Team
    Editorial Team
    2026-05-16T11:08:40+00:00Added an answer on May 16, 2026 at 11:08 am

    It seems like this is caused by a bug in the player. I’ve encountered this same problem a while ago. It’s described here:

    https://bugs.adobe.com/jira/browse/ASC-3529

    There’s a workaround, which basically consists in loading the swf with an URLLoader (as binary) and then using Loader::loadBytes (instead of just using a regular Loader).

    Here’s an explantion of this workaround and a loader class that fixes this problem:

    http://blog.aleksandarandreev.com/?p=42

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm making a simple page using Google Maps API 3. My first. One marker

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.