访问类变量槽其他类 [英] Access a variable in a class trough another class
问题描述
noob问题(可能)。我有一类与 VAR textFieldObjets:文本字段
在我班上的 ENVIRONNEMENT
Noob question (probably). I have a class with a var textFieldObjets:Textfield
in my class environnement
我想要做的,是从另一个类访问此var和更改文本。我试着像 environnement.textFieldObjets.text =布拉布拉;
遇到错误1119,一个可能未定义的属性textFieldObjets进入低谷静态类型类的参考。我甚至不能访问我的环境在班......
What i'd like to do, is access this var from another class and change the text. I tried things like environnement.textFieldObjets.text = "blabla";
Got error 1119, Access of a possible undefined property textFieldObjets trough a reference with static type Class. I can't even access my environnement class...
我怎么能这样做呢? THX!
How could I do that? thx!
推荐答案
请变量的类成员与公共静态
标识。
Make the variable a class member with public static
identifier.
public static var textFieldObjects:Textfield;
有关什么静态
和公开
关键词的意思是,你可以参考这个问题的更多信息:<一href="http://stackoverflow.com/questions/1738349/actionscript-3-can-someone-explain-to-me-the-concept-of-static-variables-and-met">Actionscript 3:有人能向我解释静态变量和方法
For more information on what static
and public
keywords mean, you could refer to this question: Actionscript 3: Can someone explain to me the concept of static variables and methods?
从Adobe的文档:<一href="http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f30.html" rel="nofollow">http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f30.html
这篇关于访问类变量槽其他类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!