You'd need to instantiate the other class and then access it, like this:
package test {
public class test2 extends Sprite {
public function test2(){
var testInstance:test = new test();
trace(testInstance.hello);
}
}
}
Also, it's good practice to capitalise your class names: Test, Test2
rather than test, test2.
Piers
On 12 Jun 2008, at 13:33, Johnny Zen wrote:
Hi all
I am currently learning AS3, and I seem to be a bit confused on
understanding accessing variables outside of the class it resides in.
for example:
------------------------------------------------
package test {
public class test extends Sprite {
public var hello = "hello";
}
}
--------------------------------------------
I thought this var will be available to access from within another
class like this:
--------------------------------------------
package test {
public class test2 extends Sprite {
hello = "hello from another class";
}
}
-----------------------------------------------
But I get :
1120: Access of undefined property hello.
Is anyone kind enough to put me right ?
Thanks
Johnny
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[EMAIL PROTECTED]
0207 631 3278
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders