Using ASFunction to Call Class Methods

One of the problems with ASFunction is that it will not let you call class methods. This is inconvenient if you are using your own custom class that builds an interface, and you need to have clickable links within a text field. A couple of solutions that I have seen uses a homemade proxy class or the built-in Delegate class to do it, but there is another way to do it that uses the same technique that is used within the XML object and within event handlers to retain the handle to the class instance. When an ASFunction link is clicked, the text field automatically looks to the parent movie clip for the function to call. A proxy function is placed in the text field’s parent movie clip, then a “parent” variable is created to hold the reference to the class instance. That variable is visible within the proxy function, and allows the function to then “redirect” to the class method.