English 中文(简体)
AS3: 外部舱面的存取功能
原标题:AS3: Access function in external class located in external swf

I am trying to access a function in a loaded swf that has external class.. I would like to avoid having to put the function on my "Main" Doc class in the external swf and instead access the function directly from the class

这正是迄今为止所尝试的,它无所作为:

 private function startLoad(){
        var loader:Loader = new Loader();
        var req:URLRequest = new URLRequest("one.swf");
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
        loader.load(req);

    }
 private function onLoadComplete(e:Event):void{
        var ClassDefinition:Class = e.target.applicationDomain.getDefinition("com.view.Creative") as Class;
        var butn:MovieClip = new ClassDefinition(0,0);////0,0 is x and y cordinates I have in the "com.view.Creative" class

        this.addChild(butn);
        butn.setVar("one");////"setVar" is the function in my external swf with the class "com.view.Creative"
    }

这是 com。 创造性。

  public var storedVar:String

  public function setVar(str:String):void{
               this.storedVar = str;
               trace(storedVar)
    }

/Returns “ReferenceError: Error # 1069: Property setVar not found on com.view. 创造性,没有违约值

This is the other approach I took with no success

  private function startLoad(){
        var appDomain:ApplicationDomain = new ApplicationDomain();
        var context:LoaderContext = new LoaderContext(false, appDomain);
        var loader:Loader = new Loader();
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler); 
        loader.load(new URLRequest("one.swf"), context);


    }

  private function completeHandler(event:Event):void { 
        var myGreet:Class = ApplicationDomain.currentDomain.getDefinition("com.view.Creative") as Class;                
        var app : MovieClip = new myGreet(0,0)
        addChild(app);
        app.setVar("one");////set var is the function in my external swf with the class "com.view.Creative" I am trying to access
        //event.target.content.setVar("one");///this works if I am placing my "setVar" function on my "Main" Doc Class which I am trying to avoid///

    }

这是 com。 创造性。

   public var storedVar:String

   public function setVar(str:String):void{
               this.storedVar = str;
               trace(storedVar)
    }

//Returns "ReferenceError: Error #1069: Property setVar not found on com.view.Creative and there is no default value. at com.util::ClickArea/completeHandler()"

这是一项解决办法。 先进经验!

最佳回答

第二例审判:

 var myGreet:Class = event.target.applicationDomain.getDefinition("com.view.Creative") as Class;  

活动。 目标是你的内容。

如果你把w子装入新的应用程序,那么你不能在目前的Domain寻求定义。

第一种情况: 你们已经根据这些内容有创造力的阶层,但是有不同的寄生虫和时间。 页: 1 创造力不会超过现有标准,而是从主食中恢复。

问题回答

暂无回答




相关问题
Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

JSON with classes?

Is there a standardized way to store classes in JSON, and then converting them back into classes again from a string? For example, I might have an array of objects of type Questions. I d like to ...

Object-Oriented Perl constructor syntax and named parameters

I m a little confused about what is going on in Perl constructors. I found these two examples perldoc perlbot. package Foo; #In Perl, the constructor is just a subroutine called new. sub new { #I ...

Passing another class amongst instances

I was wondering what is the best practice re. passing (another class) amongst two instances of the same class (lets call this Primary ). So, essentially in the constructor for the first, i can ...

Where can I find object-oriented Perl tutorials? [closed]

A Google search yields a number of results - but which ones are the best? The Perl site appears to contain two - perlboot and perltoot. I m reading these now, but what else is out there? Note: I ve ...

热门标签