CodeDemen
CodeDemen

Reputation: 1971

How to extend class that is inside a loaded swf

I've got an swf loaded externally to my app with loader component. It is loaded to the Application Domain of my loader. I've got a class in that swf wich I would like to extend and override some functions from it. Is it possible somehow? Here is some code to explain what I want(of course, it is fully incorrect and wold not work):

public var ClassFromLoadedSwf:Class = ApplicationDomain.currentDomain.getDefinition("path.to.needed.class") as Class;
public class MyClass extends ClassFromLoadedSwf
{
    override protected function initMovie() : void
    {
         //function logic goes here
    }
}

Thank you for your answers and sorry for my bad english.

Upvotes: 2

Views: 214

Answers (1)

Gio
Gio

Reputation: 1954

No you can't. Basically you don't understand the meaning of ApplicationDomain. Using a loader and Applicaiton Domain you just merge some code to your SWF in Runtime. Before it reaches the Runtime state, it can't be accessed. So at the Compile time you can't do what you're trying to do now. But you can try to use SWC instead of SWF. You just include it in your Project Library and that's all. You'll be able to access all the classes at compile time. Try reading this Article. It will help you understand the meaning of SWCs.

Upvotes: 8

Related Questions