Main Class : -
public class Main extends Sprite {
public function Main() {
loadStarling();
}
private function onRootCreated(event: starling.events.Event, root: Game): void {
myRoot = root;
myRoot.startGame();
star.removeEventListener(starling.events.Event.ROOT_CREATED, onRootCreated)
}
public function loadStarling(): void {
Texture.asyncBitmapUploadEnabled = SystemUtil.isIOS;
//Starling.multitouchEnabled = true;
if(star != null)
{
star.dispose();
}
star = new Starling(Game, stage, viewPort, null, "auto", ["baselineExtended", "baseline"]);
star.supportHighResolutions = true;
//star.simulateMultitouch = true;
//star.showStats = true;
star.skipUnchangedFrames = true;
star.antiAliasing = 1;
star.addEventListener(starling.events.Event.ROOT_CREATED, onRootCreated);
star.start();
}
}
Game Class : -
public class Game extends Sprite {
public function Game() {
//Game Initiated
}
public function startGame():void{
//Game Started
}
public function reloadGame():void{
//Starling.current.root.dispose();
Starling.current.root.loadStarling(); // giving error
}
}
I believe the above code explains what I am trying to do.