ignore the lack of constructors etc so Hi has an instance of Hello and can directly reference it. is there a way to reference Hi from Hello? You can't use parent because you have to addChild first.
I could write the constructor of Hello so that you pass it an object... so insert this into the Hello class
public var parentThing:Object; public function Hello(pT:Object){ parentThing = pT; }
but I wanted to know if there was a built in property or something
This kind of thing usually requires some sort of custom event in order to communicate between the two classes. If you haven't read about custom events and the dispatchEvent method than I recommend reading about it like ostcount=80">here or here. It's a little confusing at first but that is probably the method I would recommend for this kind of situation.
There are many ways, but because you do not name any context, it's hard to say which is the best.
You can give Hi static vars/functions You can pass a reference You can use an interface
Typically it's not good practice to traverse up a tree, only down one. Any objects/functions/interfaces that the child needs to interact with should be given to it by the parent (or grandparents further up). You should never have the entire tree open to a single node way down the list that only needs minimal information to complete its job.
Yeah I know the whole situation is a little... completely not OOP. An dank, I normally try to follow the general ideas of encapsulation, it's just I was hoping to be able to access an updating value of the parent class. I've ended up just going with an event listener like LonLon said.
This next part is basically an unrelated question but I don't feel like starting a new thread (yet). Speaking of static functions, I had a function that calculated the distance between points that I was going to use in several different classes, so I made a MyMath class that held that and several other such functions. Flash won't recognize it when I call MyMath.getDistance(blah) unless I make getDistance a static function... I don't know why. (btw ignore the blah, the actual arguments aren't important)
Ok so I had to put it as static to use it that way because that's apparently what "static" does to functions... I didn't really know what it did to functions before, just that with variables it makes it so all instances of the class use the same instance of that variable. So thanks.
And I did not know that about the point class. Thanks again =P