Got it. Like a dummy, I forgot to add "extends Sprite" after the class declaration.
Actionscript 3 addChild problems
-
11-06-2023 - |
Question
The error messages from FlashDevelop are rather difficult to translate.
I'm using addChild in several situations, generally with no problems. However, every once in a while I get:
Error: Call to a possibly undefined method addChild.
However, the exact same code works in other classes, and I am importing exactly the same files. Obviously addChild is not an undefined method! Here's the code- works in one module, doesn't work in another.
public var artist:Loader;
public var artistName:Loader;
public function SceneTJ():void {
artistName = new Loader();
artistName.load(new URLRequest("images/artistname.jpg"));
artist = new Loader();
artist.load(new URLRequest("images/artist.jpg"));
artistName.x = artistName.y = 0;
artist.x = 0;
artist.y = 0;
addChild(artist);
addChild(artistName);
}
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow