简体   繁体   English

Adobe AIR getQualifiedDefinitionNames

[英]Adobe AIR getQualifiedDefinitionNames

I have a problem with getQualifiedDefinitionNames, when I compile with AIR 20 I get 我使用AIR 20进行编译时,getQualifiedDefinitionNames出现问题

Main gameBg_png$c19135a2672bad8837da970f47c7278f-30390368 主游戏Bg_png $ c19135a2672bad8837da970f47c7278f-30390368

and when I compile with Apach Flex 4.15.0 or Adobe Animate CC it returnes everything as expected! 当我使用Apach Flex 4.15.0或Adobe Animate CC进行编译时,它会按预期返回所有内容!

Main Main__gamebg Main Main__gamebg

how to fix it with AIR, that it returned Main__gamebg class? 如何用AIR修复它,它返回Main__gamebg类?

my sample code: 我的示例代码:

package{
   import flash.display.MovieClip;  
   import flash.events.Event;  

   public class Main extends MovieClip {  

   [Embed(source="../assets/gameBg.png")]  

   public const _gamebg:Class;  

  public function Main() {  
    super();  
    if (stage) init();  
    else addEventListener(Event.ADDED_TO_STAGE, init);  
  }  

 private function init(e:Event = null):void {  

     removeEventListener(Event.ADDED_TO_STAGE, init);  
     var definitions:*;  
     if (this.loaderInfo.applicationDomain.hasOwnProperty("getQualifiedDefinitionNames")) {  
       definitions = this.loaderInfo.applicationDomain["getQualifiedDefinitionNames"]();  
       for (var i:int = 0; i < definitions.length; i++) {  
           trace(definitions[i])  
       }  
      }  
    }  
  }  
}

http://forum.starling-framework.org/topic/getqualifieddefinitionnames-porblem?replies=5#post-90611 http://forum.starling-framework.org/topic/getqualifieddefinitionnames-porblem?replies=5#post-90611

this trick works. 这个技巧有效。

///////////////
// SomeImage.as
///////////////
[Embed(source="someimage.png")] 
public class SomeImage extends Bitmap{
public function get dimensions(): String{
    return width + "x" + height;}
}

/////////////
// MyClass.as
/////////////
public class MyClas{
   public function foo(): void{
     // Instantiate the bound class to get the embedded image
     var someImage:SomeImage = new SomeImage();

     // ... do whatever you'd like with someImage
     trace("Dimensions: " + someImage.dimensions);
   }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM