AS3 getDefinitionByName - 错误#1065:变量{类名称}没有定义 [英] AS3 getDefinitionByName - Error #1065: Variable {class name} is not defined

查看:284
本文介绍了AS3 getDefinitionByName - 错误#1065:变量{类名称}没有定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是不是标题所暗示的稍微复杂一些。我的公司已在20个flash游戏该地区的工作。我们的球员也有替身,他们可以自定义这些头像是用来里面我们的游戏。

我们具有由我们的preloader加载,然后进入GameName.swf一个文件,Avatar.swf。我想借此阿凡达影片剪辑,并创建一个工厂类,所以我们可以有内我们的游戏它的许多实例。

我可以从装载机阿凡达影片剪辑实例没有问题。有两种方法,我知道得到一个构造函数从一个实例在AS3中。

1)对象(将myInstance).constructor为Class

2。)getDefinitionByName(的getQualifiedClassName(将myInstance))为类

1间歇工作,但在3个约1时我得到抛出的最终实例空引用错误。我不知道为什么,但它不是一个一致的问题。这几乎就像如果脚本是有,但资产库中是没有的。这既发生在调试模式和发布模式。这也恰好这两个编译时使用的FlashDevelop和CS5.5。

2引发Error#1065:变量头像没有定义。我是这样理解的,因为我还没有进口的头像包,并宣布阿凡达的虚拟实例,但是这是整点。如果我们通过添加衣服,例如一个新的项目更改头像,我们绝对不希望要经过我们不断扩大的游戏列表,并重新编译他们。换句话说,我不希望阿凡达code在每场比赛,这将否定加载它在我们的preloader点。

有没有人有什么建议?

谢谢!

解决方案
  1. 确保您的Avatar.swf被加载到同一个应用领域
  2. 确保你已经在使用的每个分身类至少一次(例如,在Avatar.swf的文档类),或者如果他们的Flash库项目,将其导出为Avatar.swf帧1。

My issue is slightly more complicated than the title suggests. I work for a company that has in the region of 20 flash games. Our players also have avatars which they can customise and these avatars are used inside our games.

We have a file, Avatar.swf which is loaded by our preloader and then passed into GameName.swf. I want to take this Avatar movieclip and create a factory class so we can have many instances of it inside our games.

I can get an instance of the Avatar movieclip from the loader without a problem. There are two way I know of to get a constructor from an instance in AS3.

1.) Object(myInstance).constructor as Class

2.) getDefinitionByName(getQualifiedClassName(myInstance)) as Class

1 works intermittently but about 1 time in 3 I get a null reference error thrown by the resultant instance. I have no idea why but it is not a consistent problem. It's almost as if the scripts are there but the assets library isn't. It happens both in debug mode and release mode. It also happens both when compiled using FlashDevelop and CS5.5.

2 throws Error #1065: Variable Avatar is not defined. I understand this is because I have not imported the Avatar package and declared a dummy instance of Avatar but this is the whole point. If we change the avatar by adding a new item of clothing for example, we definitely do not want to have to go through our ever expanding list of games and recompile them all. In other words, I do not want the Avatar code in every game, it would negate the point of loading it in our preloader.

Does anyone have any suggestions?

Thanks!

解决方案

  1. Make sure your Avatar.swf is loaded into the same application domain.
  2. Make sure you have used each of the avatar classes at least once (e.g. in the document class of Avatar.swf), or if they are Flash library items, export them into frame 1 of Avatar.swf.

这篇关于AS3 getDefinitionByName - 错误#1065:变量{类名称}没有定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆