I'm pretty sure that by "parent" he meant displayList parent, rather than superclass.
The quick and dirty answer is that you can cast the parent to MovieClip to access dynamic properties:
The more involved answer is that you should not be reaching up the displayList to access things because that tightly couples the two classes (they no longer work independently).Code:var parentmc:MovieClip = parent as MovieClip; trace("the value of WantThis in my parent class is "+parentmc.getWantThis());
You could define an interface which declares getWantThis and have your main class implement it. Then you can have a method in MyClass which takes an instance of that interface and uses it.
interface:
main:Code:package { public interface WantThisProvider{ function getWantThis():int; } }
MyClass:Code:package { public class Main extends MovieClip implements WantThisProvider{ var WantThis:int = 7 var myObject:MovieClip public function Main(){ myObject = new MyClass(); myObject.setWTProvider(this); addChild(myObject) } public function getWantThis():int{ return WantThis; } } }
Code:package { public class MyClass extends MovieClip{ private var wtprovider:WantThisProvider; public function MyClass(){ } public function setWTProvider(wt:WantThisProvider):void{ wtprovider = wt; } public function testWT():void{ trace("the value of WantThis in my wtprovider is "+wtprovider.getWantThis()); } } }




Reply With Quote