I’m switching to full OOP programming since I have nothing else to do other than to learn the same language again. Anyway I’ve got a question about accessing public vars in a subclass:
Test.as
package
{
import flash.display.Sprite;
import SubTest;
public class Test extends Sprite
{
public var _sW:uint;
public var subTest:SubTest;
public function Test()
{
subTest = new SubTest();
trace("This is the Test class", sW); // returns stageWidth normally;
}
public function get sW():uint {
_sW = stage.stageWidth;
return _sW;
}
}
}
SubTest.as
package
{
public class SubTest
{
public function SubTest()
{
trace("This is the SubTest class", sW); // I get an unknown variable sW;
}
}
}
Why can’t I call the get sW method from the Test.class since it is public method and resides within the same package?