I want to call the function handleText from another file.
package
{
import flash.display.MovieClip;
public function handleText(mc:MovieClip):void
{
mc.text="aaaaaa";
}
}
But when I call the function handleText from another file (which is in the same directory as the file with the above code, also with “package {” on top), I get an error of undefined function. What is wrong? Thanks!
I suppose you are talking about something like Categories in Objective-C where developers are able to add functionality to a class in a separate file without needing to modify the original class code? If so, then no. Since classes and their structure in AS3 is heavily connected to the file structure, there is no way to extend the functionality in already defined classes in separate files.
However, you can add/modify functionality of classes using inheritance. That way you can add, for example, methods and variables in separate .as files, but the new class will be treated as a separate class with its own name.