So I recently learnt that by importing a class into my main class I can access its functions from any other class. BUT.... one of my functions in the imported class needs to add display objects to the stage. I accessed the static function just fine but it can't add objects to the stage. It doesn't even seem to recognise addChild. Is this because it is not in the display list itself?
What am I missing here? How would you guys solve this issue. I was so close, yet so far!
Code is like this:
package {
import flash.display.Sprite;
import PopHandler;
public class MyMainClass extends Sprite {
public function MyMainClass():void {
PopHandler.LaunchPop();
}
}
}
This is the imported class that doesn't add anything to stage.
package {
import flash.display.Sprite;
public class PopHandler extends Sprite {
public function PopHandler():void {
}
public static function LaunchPop() {
var bp:BreakPop = new BreakPop();
bp.x = 500;
bp.y = 347;
addChild(bp);
}
}
}
BreakPop being an item in my library.
Thanks in advance.