作者:loto1115丨 | 来源:互联网 | 2023-05-19 17:42
Ihavethissituation.Iwasbuildingallincode,butitsalittlepainful,soImadeainterface
I have this situation. I was building all in code, but it's a little painful, so I made a interface with components using the Flash drawing capabilities.
我有这种情况。我构建了所有代码,但是有点痛苦,所以我使用Flash绘图功能创建了一个与组件的接口。
I got a main class, as usual, with the interface in a MovieClip instance called "AreaEdit". In my custom class "EditorHTML" there is a Sprite:
像往常一样,我在一个名为“AreaEdit”的MovieClip实例中获得了一个主类。在我的自定义类“编辑器”中有一个精灵:
private var dTela:Sprite;
So the constructor is like this:
构造函数是这样的
public function EditorHTML(instEdit) {
this.Parags = new Array();
this.dTela = instEdit;
trace("dTela: "+this.dTela.width+" x "+this.dTela.height);
}
At the main class:
在主类:
Escrit = new EditorHTML(AreaEdit);
So trace displays the dimensions of the box, as expected. However, at the custom class, if I try to access an instance inside like this:
因此,trace将按预期显示该框的大小。但是,在自定义类中,如果我尝试访问这样的实例:
this.dTela.cxEdit.addEventListener(Event.CHANGE, atualizar);
An error is returned: /Library/WebServer/Documents/as3/bibliotecas_externas/com/gustavopi/txt/EditorHTML.as, Line 49 1119: Access of possibly undefined property cxEdit through a reference with static type flash.display:Sprite.
返回一个错误:/Library/WebServer/Documents/as3/bibliotecas_externas/ com/gustavopi/txt/editorhtml。如,第491119行:使用静态类型flash的引用访问可能未定义的属性cxEdit。显示:Sprite。
I did a test and the same instance "cxEdit" is available in main class. So it seams the components instances are not available for a custom class. How do I solve this?
我做了一个测试,同样的实例“cxEdit”在主类中可用。因此,对于自定义类来说,组件实例是不可用的。怎么解呢?
2 个解决方案